Set
Set is a special type of collection that only collect unique data no
duplicates are allowed.
Key features
Unique value only.
Keeps order: items are returned in the same order as you inserted
them.
Faster operations at the Backend set uses something called
Hash table, which make adding, deletion, searching very fast.
No index unlike array set have doesn’t have numbered
positions(index).
For…. Of loop or forEach loop can be used.
// Creating set
1. From an array:
Let v1=new set([10,20,10,12,23,20])
[Link](v1);
2. From String
Let v2= new se([10,20,30,10,30,14])
[Link](v2);
//How elements are ordered in set
Using for …. Of
Let sample = new set();
[Link](“qw”);
[Link](“qws”);
[Link](“qxw”);
Let d=[Link]();
For(let val of d){
[Link](val);
}