📝 Edit page
➕ Add page
Iterables
From Iteration protocols:
String,Array,TypedArray,Map, andSetare all built-in iterables, because each of their prototype objects implements an@@iteratormethod.
Make an iterator
const myIterable = {};
myIterable[Symbol.iterator] = function* () {
yield 1;
yield 2;
yield 3;
};
console.log([...myIterable]); // [1, 2, 3]