How to check if a set is empty in TypeScript

1 Answer

0 votes
const aset = new Set();

console.log(aset.size); 

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




/*
run:
 
0
"empty"
  
*/
  

 



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

Related questions

1 answer 100 views
2 answers 165 views
1 answer 129 views
2 answers 194 views
1 answer 134 views
...