javascript last element of an array
snippet in javascript

javascript get last element of array

user6972

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

last element of array javascript

user9256

var my_array = /* some array here */;
var last_element = my_array[my_array.length - 1];

javascript last element of an array

user4173

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

find last element in array javascript

user4822

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

javascript last item in array

user7228

// Find the last item in an array.

arrayName[arrayName.length - 1]

javascript take last element of array

user3443

let array = [1,2,3,4,5];
let lastElement = array.pop();

// array -> [1,2,3,4];
// lastElement = 5;