Answers for "get the last n element in an 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
2

javascript get last element of array

console.log([1,2,3,4].reverse()[0]);
Posted by: Guest on April-09-2022

Code answers related to "get the last n element in an array js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language