Answers for "how to select the last element in an array"

80

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
0

how to select last element in a array

if (loc_array[loc_array.length - 1] === 'index.html') {
   // do something
} else {
   // something else karunakar
}
Posted by: Guest on August-04-2020

Code answers related to "how to select the last element in an array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language