javascript get last element of array
var foods = ["kiwi","apple","banana"];
var banana = foods[foods.length - 1]; // Getting last element
get last element of array javascript
var numbers = ["one", "two", "three"];
var lastnumber = numbers[numbers.length - 1];
console.log(lastnumber);
javascript last element of array
let arr = ['a', 'b', 'c']
arr.slice(-1)[0] // returns last element in an array
how to get the last eleemnt of an array
var Cars = ["Volvo", "Mazda", "Lamborghini", "Maserati"];
//We can get the total number of elements like this.
var hmCars = Cars.pop();
//hmCars is now Maserati
console.log(hmCars)
js get last array element
const array = [1, 2, 3, 4]
const lastArrayElement = array[array.length - 1]
javascript get last element of array
console.log(2)