Open In App

How to Create an Empty Set in JavaScript ?

In JavaScript, you can create an empty Set using the Set constructor.

Syntax:

let emptySet = new Set();

Example: Here, new Set() creates a new Set object, and emptySet is assigned to that newly created Set. This Set is initially empty, with no elements in it.




let emptySet = new Set();
console.log(emptySet);

Output
Set(0) {}
Article Tags :