Answers for "how to print last element of array in first javascript"

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

es6 get first and last element of array

let {0 : a ,length : l, [l - 1] : b} = [1,2,3,4,5,6,7,8,9,0];
console.log(a, b)
Posted by: Guest on May-05-2021

Code answers related to "how to print last element of array in first javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language