JS: Iterator.prototype
What is Iterator.prototype
Iterator.prototype is the value of the property key "prototype" of the function Iterator. 〔see Iterator Object〕
console.log(Object.hasOwn(Iterator, "prototype"));
Type
Type of Iterator.prototype is Object
.
console.log(typeof Iterator.prototype === "object");
Parent
Parent of Iterator.prototype is Object.prototype
.
// parent of Iterator.prototype console.log(Reflect.getPrototypeOf(Iterator.prototype) === Object.prototype);
Purpose
Allow all standard Iterable objects to have methods such as map, forEach, filter, etc, without having to convert to array first. Similarly, modify given Iterator to return a new iterator.
Properties
constructor-
value is
Iteratorconsole.log(Iterator.prototype.constructor === Iterator); // true
- JS: Iterator.prototype.map
- JS: Iterator.prototype.forEach
- JS: Iterator.prototype.filter
- JS: Iterator.prototype.reduce
- JS: Iterator.prototype.take
- JS: Iterator.prototype.drop
- JS: Iterator.prototype.every
- JS: Iterator.prototype.some
- JS: Iterator.prototype.find
- JS: Iterator.prototype.flatMap
- JS: Iterator.prototype.toArray
Symbol.iteratorSymbol.toStringTag
JavaScript. Iterable, Iterator
- JS: Iterable Object
- JS: for-of Loop
- JS: Array.from
- JS: Spread Operator (triple dots)
- JS: Iterator
- JS: Iterator.prototype
- JS: Generator
- JS: Generator Function (asterisk)
- JS: Interface
- JS: Iterable Interface
- JS: Iterator Interface
- JS: IteratorResult Interface
- JS: Test If Object is Iterable or Iterator 📜