Parameters
- input: Input[]
- transform: ((input: Input, index: number) => undefined | Output)
- (input, index): undefined | Output
Parameters
- input: Input
- index: number
Returns undefined | Output
The items returned by transform()
, with any undefined items removed.
This is like calling
input.map(transform).filter(item => item !=== undefined)
. But if I used that line typescript would get the output type wrong.Array.prototype.flatMap()
is a standard and traditional alternative.