Answers for "how to check last index of array in javascript"

29

last index array javascript

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

javascipt get last element of array

const arr = [1,2,3] ;
console.log(arr[arr.length - 1]);
Posted by: Guest on June-18-2020
1

find last element in array nodejs

var a = loc_array.slice(-1)[0]
Posted by: Guest on August-13-2020
1

js get last element of array

var last_element = my_array[my_array.length - 1];
Posted by: Guest on January-01-2021
0

find last item in an array JS

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 "how to check last index of array in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language