Knowledgize

.with(index, value)

Returns a new array with the element at the specified index replaced with a new value, without changing the original array.

Examples:

const originalArray = [1, 2, 3]; const newArray = originalArray.with(1, 22); console.log(newArray); // [1, 22, 3] console.log(originalArray); // [1, 2, 3]