JavaScript dernier élément du tableau
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
console.log([1,2,3,4].reverse()[0]);
if (locArray.at(-1) === 'index.html') {
// do something
} else {
// something else
}