javascript get last element in array

JavaScript
var colors = ["red","blue","green"];
var green = colors[colors.length - 1];//get last item in the arrayconst heroes = ["Batman", "Superman", "Hulk"];
const lastHero = heroes.pop(); // Returns last elment of the Array
// lastHero = "Hulk"this = array[array.length - 1];var array =[1,2,3,4];
var last= array[array.length-1];//why was this a ad//im here because the ad
Source

Also in JavaScript: