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 112 views
1 answer 135 views
2 answers 195 views
2 answers 245 views
2 answers 247 views
...