Answers for "take last value of array"

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
0

javascript get last emlement array

const arr = [1,2,3,4]
console.log(arr.at(-1)) // 4
Posted by: Guest on February-18-2022
0

how to get last element of an array

import _ from 'lodash';
let array = [ 1, 2, 3 ];
_.last(array); // 3
Posted by: Guest on April-18-2021

Code answers related to "take last value of array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language