The array to copy and change.
The index of the element to change.
The value to set.
Optional
Suppress errors if range is incorrect.
A new array with the element at index replaced with value.
arrayBasicWith
Change the value of a given index. It returns a new array.
Incorrect index.
0.3.62
const array = [1, 2, 3];const index = 2;if (index in array) { const copy = arrayBasicWith(array, index, 300); console.log(array); // [1, 2, 3] console.log(copy); // [1, 2, 300]} Copy
const array = [1, 2, 3];const index = 2;if (index in array) { const copy = arrayBasicWith(array, index, 300); console.log(array); // [1, 2, 3] console.log(copy); // [1, 2, 300]}
The array to copy and change.