javascript Set of Define

let name=new Set(["APC","dilip","dilip","rohit","kartika"]);

console.log(name);

console.log(name.size);


// we have create set ;

let x=new Set();


x.add("APC");

x.add("kapil");

x.add("aditi");

x.add("kajal");

console.log(x);

console.log(x.size);


console.log("Print the all set Value ");

let text="";

x.forEach(function(value){

    text+=value+"\n";

});


console.log(text);

console.log(x.values());


let y=new Set();


y.add("APC");

y.add("kapil");

y.add("aditi");

y.add("kajal");


for(let i of y.values()){

    console.log(i);

}


Post a Comment

0 Comments