JavaScript Zdobądź ostatni element tablicy
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
var a = loc_array.slice(-1)[0]
var last = arr[arr.length - 1]
var languages = ["JS", "PHP", "JAVA"]
var lastElement = languages[languages.length - 1]
console.log(lastElement)
f (loc_array[loc_array.length - 1] === 'index.html') {
// do something
} else {
// something else
}
var colors = ["green", "blue", "red"]
var lastElem = colors.at(-1)