Answers for "js set get first value"

0

js set get first value

set.values().next().value
Posted by: Guest on March-14-2021
0

javascript get first entry from set

var x = new Set();
x.add(1);
x.add({ a: 2 });
//get iterator:
var it = x.values();
//get first entry:
var first = it.next();
//get value out of the iterator entry:
var value = first.value;
console.log(value); //1
Posted by: Guest on April-27-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language