Answers for "how to take last word in list in javascript"

25

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

javascript last in a list

let list = ["item1", "item2", "item3", "etc"];
let last = list.reverse()[0]
// or
let last = list[list.length - 1]
// or
let last = list.slice(-1)
Posted by: Guest on February-20-2021

Code answers related to "how to take last word in list in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language