JavaScript mendapatkan elemen array terakhir
var colors = ["red","blue","green"];
var green = colors[colors.length - 1];//get last item in the array
Friendly Hawk
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
console.log([1,2,3,4].reverse()[0]);
var colors = ["red","blue","green"];
var green = colors[colors.length - 1]; //get last item in the array
Last Item In Array