javascript get last element of arry code example
Example 1: get last element of array javascript
var numbers = ["one", "two", "three"];
var lastnumber = numbers[numbers.length - 1];
console.log(lastnumber);
Example 2: get last element of array javascript
if (loc_array[loc_array.length - 1] === 'index.html') {
// do something
} else {
// something else
}