Open In App

How to Create an Empty Set in JavaScript ?

Last Updated : 01 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

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.

Javascript




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


Output

Set(0) {}

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads