Answers for "js extract last elems"

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

js get last element of array

var arr = [1, 2, 3];
var last_element = arr.reverse()[0];
Posted by: Guest on August-09-2021

Code answers related to "js extract last elems"

Code answers related to "Javascript"

Browse Popular Code Answers by Language