interleaveArray()function
interleaveArray(items: PossibleArray<T>, separator: T): ImmutableArray<T>
interleaveArray(items: PossibleArray<A>, separator: B): ImmutableArray<A | B>
| Param | Type | |
|---|---|---|
items | PossibleArray<T> | The array or iterable to interleave. required |
separator | T | The value to insert between each pair of items. required |
items | PossibleArray<A> | Things that can be converted to arrays. required |
separator | B | required |
| Return | |
|---|---|
ImmutableArray<T> | A new array with separator inserted between items, or the same array if it had fewer than two items. |
ImmutableArray<A | B> | Immutable array: an array that cannot be changed. |
Interleave array items with a separator.
Examples
interleaveArray([1, 2, 3], 0) // [1, 0, 2, 0, 3]