Array.prototype.withadvancedconst arr = [1, 2, 3]
arr.with(0, 10).with(2, 30) // β [10, 2, 30]Chain with() calls to replace multiple elements in immutable pipeline style.
with() returns a new array, so it can be chained. Use reduce to apply a list of [index, value] changes one after another.
Implement setMultiple(arr, changes) where changes is an array of [index, value] tuples.