JavaScripture
Contribute via GitHub Feedback

Iterator : Iterable

An Iterator is an Object that returns a sequence of values.

Since Iterators are Iterables, you can use for (var value of iterator) {} to easily loop over the values in an iterator.

Calling an ECMAScript 2015 generator function (function*() {}) returns an Iterator.

See Iterable for more details.

Instance Indexers

Returns a method that returns this.

Example:

Run

Results:

 

Instance Methods

next([yieldValue : Object]) : Object
return : {
value :Object
done :Boolean
}

Returns an object containing the next value in the iterator. If all items have been returned, done will be true. For generator functions, yieldValue is returned to the generator from the yield statement.

Example:

Run

Results: