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