Answers for "how to take last position in an array"

76

javascript get last element of array

var colors = ["red","blue","green"];
var green = colors[colors.length - 1];//get last item in the array
Posted by: Guest on February-19-2020
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 "how to take last position in an array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language