To reverse an array in Typescript, we can use the reverse()
method provided by arrays. The reverse()
method permanently changes the original array, mutating it in place.
index.ts99 chars4 lines
If we want to create a new array with reversed elements without changing the original, we can create a copy of the original array using the spread operator (...
) and then reverse the copied array.
index.ts177 chars5 lines
gistlibby LogSnag