Four pairs called for real on train #1: sort, reverse, splice and arr[i] = v change that train itself, toSorted, toReversed, toSpliced and with bring a new…
The key idea
The 'to' prefix returns a copy; without 'to' changes in place
Try it in this playground
Run splice, then toSpliced splice returns the wagons it uncoupled and shortens arr; toSpliced returns what is left and leaves arr be.
Replace one wagon with with(i, v) A copy with one new wagon; try a negative index.
with off the train An index that is not there: with throws a RangeError.
Compare arr[i] = v Writing directly changes train #1; past its end it leaves empty slots.