how to get last array in javascript code example
Example 1: javascript last element of array
let arr = ['a', 'b', 'c']
arr.slice(-1)[0] // returns last element in an array
Example 2: javascipt get last element of array
const arr = [1,2,3] ;
console.log(arr[arr.length - 1]);