Iterator
优质
小牛编辑
135浏览
2023-12-01
The Iterator object provides an API for iterating over a sequence.
The purpose of the Iterator
type is mainly to offer an agnostic way of iterating over a sequence -- either synchronous (i.e. with a while
loop) or asynchronously (with recursive calls to either setTimeout
or --- if available --- setImmediate
). It is not intended to be used directly by application code.
Signature
function Iterator(sequence) { /*...*/ }
function Iterator(sequence) { this.sequence = sequence; this.index = -1; }
Name | Type(s) | Description |
---|---|---|
sequence | Sequence | The sequence to iterate over. |