Answers for "What is the index of the last element in an array in JavaScript?"

29

javascript last index

var colors = ["red","blue","green"];
var green = colors[colors.length - 1]; //get last item in the array
Posted by: Guest on July-25-2019
0

javascript code for find the last element in array

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

Code answers related to "What is the index of the last element in an array in JavaScript?"

Code answers related to "Javascript"

Browse Popular Code Answers by Language