find last element in array javascript
snippet in javascript

javascript get last element of array

user8070

var colors = ["red","blue","green"];
var green = colors[colors.length - 1];//get last item in the array

Javascript get last item in array

user5220

var colors = ["red","blue","green"];
var green = colors[colors.length - 1]; //get last item in the array

js take last item in array

user3534

const heroes = ["Batman", "Superman", "Hulk"];
const lastHero = heroes.pop(); // Returns last elment of the Array
// lastHero = "Hulk"

javascript last element of array

user3856

let arr = [1,2,3]
arr[arr.length - 1] //returns last element in an array

find last element in array javascript

user6492

var heroes = ["Batman", "Superman", "Hulk"];
var lastHero = heroes.pop(); // Returns last elment of the Array
// lastHero = "Hulk"

find last element in array javascript

user6431

const numArray = [1,2,3,4,5];
const lastNumber = numArray.reverse()[0];