JS: Iterator (Abstract class)

By Xah Lee. Date: . Last updated: .

What is the Keyword “Iterator”

Has property Iterator.prototype that is the parent of all builtin Iterator, so Iterable Object can directly use methods like forEach, map, etc.

Properties


xtodo
console.log(Reflect.ownKeys(Iterator));
// [ "length", "name", "prototype", "from" ]

console.log(Iterator.from);
// [Function: from]

console.assert(Iterator.length === 0);

console.assert(Iterator.name === "Iterator");