withArrayIndex()function
withArrayIndex(arr: ImmutableArray<T>, index: number, value: T): ImmutableArray<T>
| Param | Type | |
|---|---|---|
arr | ImmutableArray<T> | The array to update. required |
index | number | The index to replace. required |
value | T | The new value to set at index. required |
| Return | |
|---|---|
ImmutableArray<T> | A new array with value at index, or the same array if the value was unchanged. |
Return a new array with a new value replacing a specific index in the array (or the same array if the value was unchanged).
Examples
withArrayIndex([1, 2, 3], 1, 9) // [1, 9, 3]