Answers for "how to print last value off array in js"

26

js take last item in array

const heroes = ["Batman", "Superman", "Hulk"];
const lastHero = heroes.pop(); // Returns last elment of the Array
// lastHero = "Hulk"
Posted by: Guest on March-16-2020
0

get last element in array in js

f (loc_array[loc_array.length - 1] === 'index.html') {
   // do something
} else {
   // something else
}
Posted by: Guest on January-24-2021

Code answers related to "how to print last value off array in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language