JS: Set.prototype.values

By Xah Lee. Date: . Last updated: .

New in ES2015.

set_obj.values ( )

Return a iterator function for the set instance.

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

[see JS: Iterator]

[see JS: Set.prototype[Symbol.iterator]]

JS Set

  1. Set Tutorial
  2. Union, Intersection, Difference

Like it? Help me by telling your friends. Or, Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials