JavaScript последний элемент массива
let arr = [1,2,3]
arr[arr.length - 1] //returns last element in an array
Elegant Elk
let arr = [1,2,3]
arr[arr.length - 1] //returns last element in an array
var colors = ["red","blue","green"];
var green = colors[colors.length - 1];//get last item in the array
const heroes = ["Batman", "Superman", "Hulk"];
const lastHero = heroes.pop(); // Returns last elment of the Array
// lastHero = "Hulk"
var colors = ["red","blue","green"];
var green = colors[colors.length - 1]; //get last item in the array
var array =[1,2,3,4];
var last= array[array.length-1];
this = array[array.length - 1];