How to check if a key exists in a map with TypeScript

1 Answer

0 votes
const mp = new Map([
  ['javascript', 1],
  ['nodejs', 2],
  ['typescript', 3],
  ['c++', 4],
]);

console.log(mp.has('typescript')); 

console.log(mp.has('c')); 
  
  
  
  
/*
run:
  
true
false
  
*/

 



answered Jun 23, 2022 by avibootz

Related questions

1 answer 149 views
1 answer 157 views
1 answer 154 views
1 answer 128 views
1 answer 139 views
2 answers 208 views
1 answer 205 views
...