Answers for "how to get the last eleemnt of 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
10

get last element of array javascript

var numbers = ["one", "two", "three"];
var lastnumber = numbers[numbers.length - 1];
console.log(lastnumber);
Posted by: Guest on September-04-2020

Code answers related to "how to get the last eleemnt of an array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language