js take last item 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"
Source

Also in JavaScript: