Standard built-ins
Iterator.prototype.take()
Lazily produces at most the specified number of values. The limit is converted to Number and then truncated to an integer (or Infinity); NaN or a negative resulting integer throws RangeError.
Formal Syntax & Structure
javascript syntaxjavascript
iterator.take(limit)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| limit | number | Nonnegative limit; converted to integer or Infinity. |
Return Value
Iterator
Result of the operation.
Working Example
Example Snippetjavascript
console.log(JSON.stringify(Iterator.from([1,2,3]).take(2).toArray()));