array get last index in array javascript code example
Example 1: javascript get last element of array
var colors = ["red","blue","green"];
var green = colors[colors.length - 1];
Example 2: get last element of array javascript
var numbers = ["one", "two", "three"];
var lastnumber = numbers[numbers.length - 1];
console.log(lastnumber);
Example 3: javascript code for find the last element in array
if (loc_array[loc_array.length - 1] === 'index.html') {
} else {
}
Example 4: get last element in array javascript
var my_array = ;
var last_element = my_array[my_array.length - 1];