show last of array javascript code example
Example 1: last item in array javascript
// Find the last item in an array.
arrayName[arrayName.length - 1]
Example 2: last element from list javascript
const lastItem = colors[colors.length - 1]
// Find the last item in an array.
arrayName[arrayName.length - 1]
const lastItem = colors[colors.length - 1]