JS: Set.prototype.entries
(new in ECMAScript 2015)
mySet.entries()-
- Return a Generator.
- Each yield is a array of the form
[value, value].
const xx = new Set([3, 4]); for (let [k, v] of xx.entries()) { console.log(k, v); } // 3 3 // 4 4
Verify Result is a Generator
// verify the result is iterator and iterable const xx = (new Set([3, "yes"])).entries(); // is iterable console.assert(Reflect.has(xx, Symbol.iterator)); // is iterator console.assert(Reflect.has(xx, "next"));