Answers for "geeeting last element in aaray in javascript without usikng uindex"

C++
36

javascript last element of array

let arr = [1,2,3]
arr[arr.length - 1] //returns last element in an array
Posted by: Guest on June-16-2020
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

last element of array

let arry = [2, 4, 6, 8, 10, 12, 14, 16];
let lastElement = arry[arry.length - 1];

console.log(lastElement);

//Output: 16
Posted by: Guest on April-22-2022

Code answers related to "geeeting last element in aaray in javascript without usikng uindex"

Browse Popular Code Answers by Language