Answers for "getting last element from an array"

2

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)
Posted by: Guest on November-28-2020

Code answers related to "getting last element from an array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language