How to check if a set is empty in JavaScript

1 Answer

0 votes
const st = new Set();

console.log(st.size); 

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




/*
run:
 
0
"empty"
  
*/

 



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

Related questions

1 answer 105 views
1 answer 131 views
2 answers 187 views
2 answers 239 views
2 answers 237 views
...