Iterator

Draft
This page is not complete.

The Iterator global object is an abstract class providing helper methods, similar to the ones exposed on Array instances.

All built-in iterators inherit from the Iterator abstract class.

Constructor

Iterator() 
A an abstract constructor that can only be invoked using a super() call.

Properties

Iterator.prototype
The %IteratorPrototype% intrinsic object.

Methods

Iterator.from() 
Equivalent to calling @@iterator on the passed object.

Iterator prototype

Prototype properties

Iterator.prototype.constructor
Specifies the function that creates an object's prototype.
Iterator.prototype[@@toStringTag] 
The string "Iterator".

Prototype methods

Iterator.prototype.map() 
...
Iterator.prototype.filter() 
...
Iterator.prototype.take() 
...
Iterator.prototype.drop() 
...
Iterator.prototype.asIndexedPairs() 
...
Iterator.prototype.flatMap() 
...
Iterator.prototype.reduce() 
...
Iterator.prototype.toArray() 
...
Iterator.prototype.forEach() 
...
Iterator.prototype.some() 
...
Iterator.prototype.every() 
...
Iterator.prototype.find() 
...
Iterator.prototype[@@iterator]()
Returns this Iterator instance.

Implementation methods

<implementation>.prototype.next()
Gets the next item in the Iterator.
<implementation>.prototype.return()Optional
Returns the given value and finishes the iterator.
<implementation>.prototype.throw()Optional
Throws an error to an iterator (also finishes the iterator, unless caught from within that iterator).

Specifications

Specification Comment
ESNext Iterator Helpers Proposal Initial definition.

Browser compatibility

No compatibility data found. Please contribute data for "javascript.builtins.Iterator" (depth: 2) to the MDN compatibility data repository.

See also