An example of pure way getting last element of the array.
A Pen by Vlad Bezden on CodePen.
An example of pure way getting last element of the array.
A Pen by Vlad Bezden on CodePen.
const x = [1, 2, 3, 4, 5] | |
const [last] = [...x].reverse() | |
console.log(`last: ${last}, x: ${x}`) |