JS: Iterator.prototype

By Xah Lee. Date: . Last updated: .

(new in JS: ECMAScript 2025)

What is iterator.prototype and proper iterator

Iterator.prototype serves as the parent object for Iterators.

descendant of Iterator.prototype is called proper iterator.

Iterator.prototype hosts many convenient methods such as map, foreach, filter, etc, they lets you modify iterator as you do modify array.

an iterator may not be proper iterator, but you can make it so using Iterator.from, or convert any Iterable Object to proper iterator.

Properties

constructor

value is Iterator

console.assert(
 Iterator.prototype.constructor === Iterator,
);
xtodo