var heroes = ["Batman", "Superman", "Hulk"]; var lastHero = heroes.pop(); // Returns last elment of the Array // lastHero = "Hulk"
arr.slice(-1)[0]
const numArray = [1,2,3,4,5]; const lastNumber = numArray.reverse()[0];
if (loc_array[loc_array.length - 1] === 'index.html') { // do something } else { // something else }
const myArray = [1, 2, 3] console.log(myArray.item(-1)) //=> 3
var my_array = /* some array here */; var last_element = my_array[my_array.length - 1];