Standard built-ins
Iterator.prototype.flatMap()
Lazily maps each value to an iterator or iterable object and yields its elements in sequence. Primitive strings are not accepted as mapped results.
Formal Syntax & Structure
javascript syntaxjavascript
iterator.flatMap(mapper)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| mapper | function | Callback returning an iterable object or iterator. |
Return Value
Iterator
Result of the operation.
Working Example
Example Snippetjavascript
console.log(JSON.stringify(Iterator.from([1,2]).flatMap(x=>[x,x]).toArray()));