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(Iterator.hasOwnProperty("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
Iterator
console.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
xtodo
Symbol.iterator
Symbol.toStringTag