how to access last element of a rrays js code example
Example 1: javascipt get last element of array
const arr = [1,2,3] ;
console.log(arr[arr.length - 1]);
Example 2: javascript get last element in an array
var last = arr[arr.length - 1]
const arr = [1,2,3] ;
console.log(arr[arr.length - 1]);
var last = arr[arr.length - 1]