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 115 views
1 answer 93 views
2 answers 155 views
1 answer 127 views
2 answers 187 views
...