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 93 views
2 answers 156 views
1 answer 121 views
2 answers 187 views
1 answer 128 views
...