js set get first value

Solutions on MaxInterview for js set get first value by the best coders in the world

showing results for - "js set get first value"
Ian
03 Nov 2020
1set.values().next().value
Brahim
13 Jan 2017
1var x = new Set();
2x.add(1);
3x.add({ a: 2 });
4//get iterator:
5var it = x.values();
6//get first entry:
7var first = it.next();
8//get value out of the iterator entry:
9var value = first.value;
10console.log(value); //1
11