JavaScripture
Contribute via GitHub Feedback

JavaScript Iterator : Object

An Iterator is an Object that returns a sequence of values. You can use the for(var value of iterator) {} to easily loop over the values in an iterator. Calling an ECMAScript 6 generator function (function*() {}) return an Iterator. You may create your own iterable object by assigning the Symbol.iterator property to an object with a next() method.

Instance Methods

next([yieldValue : Object]) : Object
return : {
valueObject
doneBoolean
}

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 yeild statement.

Example:

Run

Results: