Answers for "node get de last element array node for"

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
28

js get last element of array

const array = ["foo", "bar", "fizz", "buzz"];
const lastElem = array.at(-1); // returns "buzz"
Posted by: Guest on March-17-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language