Loading...
const latest = messages.reverse();
render(latest);const latest = messages.toReversed();
render(latest);reverse() also flips messages; toReversed() returns a reversed copy and keeps the original.
toReversed() and ignoring the return value, expecting the array to change.[...arr].reverse().toReversed(), not reverse().toReversed() a deep copy?No. It returns a new array, but object elements are the same references.
toReversed() keep empty slots in sparse arrays?No. Empty slots become undefined in the result, so the new array is never sparse.