How to check if a map is empty in JavaScript

1 Answer

0 votes
const mp = new Map();

console.log(mp.size); 

console.log(mp.size === 0 ? "empty" : "not empty");




/*
run:
 
0
"empty"
  
*/
  

 



answered Jun 2, 2022 by avibootz
edited Jun 2, 2022 by avibootz

Related questions

1 answer 258 views
258 views asked Oct 11, 2022 by avibootz
1 answer 237 views
237 views asked Oct 11, 2022 by avibootz
1 answer 237 views
1 answer 232 views
1 answer 221 views
221 views asked Apr 13, 2020 by avibootz
1 answer 233 views
...