how to get the last item from array in javascript 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 item in array js
if (loc_array[loc_array.length - 1] === 'index.html') {
// do something
} else {
// something else
}