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

1 Answer

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

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

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

 



answered Jun 23, 2022 by avibootz

Related questions

1 answer 135 views
1 answer 147 views
1 answer 139 views
1 answer 126 views
2 answers 189 views
1 answer 188 views
1 answer 112 views
...