JS: Set.prototype.keys
New in ES2015.
set_obj.keys ( )
Return a iterator (also is a iterable) for the set instance set_obj.
Each yield of the iterator is a element of the set instance set_obj.
const ss = new Set([3,4,"ok"]); for (const e of ss.keys()) { console.log ( e ); } // prints // 3 // 4 // ok
This example shows the result is iterator and iterable:
const ss = new Set( [3,"yes"]); console.log ( ss.keys ); // [Function: values] // result is a function that returns a iterator object // call it console.log ( ss.keys() ); // SetIterator { 3, 'yes' } // result is a iterator object // is also a iterable console.log ( Symbol.iterator in ( ss.keys() ) ); // true
[see JS: Iterator]
[see JS: Symbol Tutorial]
Reference
ECMAScript 2015 §Keyed Collection#sec-set.prototype.keys
Set Topic
Patreon me $5. Ask me question on patreon