JavaScript Code


How to create an empty set in JavaScript?


Create an empty set in JavaScript

In this tutorial, you will learn how to write a JavaScript program to create an empty Set.

Solution

To create an empty set, use the Set() constructor, and pass no arguments to the constructor.

new Set();

Program

1. Create a new empty set named vowels.

const vowels = new Set();
console.log(vowels);


copyright @2022