update last value in array javascript code example
Example 1: javascript last element of array
arr.slice(-1)[0]
Example 2: javascipt get last element of array
const arr = [1,2,3] ;
console.log(arr[arr.length - 1]);
arr.slice(-1)[0]
const arr = [1,2,3] ;
console.log(arr[arr.length - 1]);