How to check if a map is empty in TypeScript

1 Answer

0 votes
const amap = new Map();

console.log(amap.size); 

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




/*
run:
 
0
"empty"
  
*/
  
  

 



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

Related questions

1 answer 123 views
1 answer 100 views
2 answers 165 views
1 answer 133 views
2 answers 195 views
...