js last items in array code example
Example 1: js take last item in array
const heroes = ["Batman", "Superman", "Hulk"];
const lastHero = heroes.pop();
Example 2: javascript code for find the last element in array
if (loc_array[loc_array.length - 1] === 'index.html') {
} else {
}
Example 3: js last array element
var linkElement = document.getElementById("BackButton");
var loc_array = document.location.href.split('/');
var newT = document.createTextNode(unescape(capWords(loc_array[loc_array.length-2])));
linkElement.appendChild(newT);