print a set javascript code example
Example 1: set in javascript
// set is used for storing unique values
const firstSet = new Set([1, 2, 3]);
firstSet.add('hi'); //adding value to set
firstSet.add(3); //this will not give any error and it will also not be added
firstSet.delete('hi');//removing value from set
console.log(firstSet.has('hi'));//checking 'hi' is in the set or not
// showing all values in the set
console.log(firstSet);
for (const entry of firstSet.values()) {
console.log(entry);
Example 2: Sets can be used to store __________. in js
let my= new Set()
my.add(1)
my.add("qw")