javascript obtient le dernier élément du tableau
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
let array = [1,2,3,4,5];
let lastElement = array.pop();
// array -> [1,2,3,4];
// lastElement = 5;
if (locArray.at(-1) === 'index.html') {
// do something
} else {
// something else
}
var my_array = /* some array here */;
var last_element = my_array[my_array.length - 1];
const array = [a,b,c,d]
let last = array[array.length - 1]
console.log(last)
// "d"