Train #1 at Stasiun Kota Kecil has index plates from the front and back: Sri asks for wagon -1 through at(), arr[-1] and arr[arr.length - 1], then writes to…
The key idea
at() understands negative indexes, brackets do not
Try it in this playground
Move i to -1 arr.at(-1) gives the last wagon, arr[-1] gives undefined.
Move past -length at() does not wrap round: it gives undefined.
Write arr[-1] = 'z' Look at Object.keys(arr) and arr.length: '-1' becomes a property, the wagons stay.
Change the last one with with(-1, v) at()'s writing twin: a new train, arr stays.