Answers for "take the last item in array 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
1

get the last element of array javascript

let array = [1, 2, 3, 4, 5]
array.at(-1) // last element on array (5)
Posted by: Guest on December-01-2021

Code answers related to "take the last item in array js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language