JavaScript: Set.prototype.values

By Xah Lee. Date: . Last updated: .

New in JS2015.

set_obj.values ( )
Return a Iterator function for the set instance. [see Iterator]
const ss = new Set ([3,4,5]);

console.log( ss.values ); // [Function: values]
// result is a function, and this function returns a iterator object

// call it
console.log( ss.values() ); // SetIterator { 3, 4, 5 }
// result is a iterator object. (which means, it has a “next” method)

console.log( ss.values().next() ); // { value: 3, done: false }
// result is a IteratorResult object

set_obj[Symbol.iterator]

set_obj[Symbol.iterator] is the same as set_obj.values.

const ss = new Set();
console.log(ss[Symbol.iterator] === ss.values); // true
JS in Depth
XAH  BUY NOW

JS in Depth

JS Obj Ref

DOM


JS Obj Ref

Set

prototype