how to retuen last eleamnt of an array code example
Example 1: javascript get the last array element
const myArray = [1, 2, 3]
console.log(myArray.item(-1))
//=> 3
Example 2: javascript get last element of array
console.log(2)
const myArray = [1, 2, 3]
console.log(myArray.item(-1))
//=> 3
console.log(2)