withArrayIndex()function

withArrayIndex(arr: ImmutableArray<T>, index: number, value: T): ImmutableArray<T>
ParamType
arrImmutableArray<T>
The array to update. required
indexnumber
The index to replace. required
valueT
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]