get last item in the array code example
Example 1: javascript get the last array element
const myArray = [1, 2, 3]
console.log(myArray.item(-1))
//=> 3
Example 2: javascript get last element of array
if (loc_array[loc_array.length - 1] === 'index.html') {
// do something
} else {
// something else
}