how to get the last item in an array javqascript code example
Example 1: javascipt get last element of array
const arr = [1,2,3] ;
console.log(arr[arr.length - 1]);
Example 2: get last item in array javascript
var colors = ["red","blue","green"];
var green = colors[colors.length - 1]; //get last item in the array