how i get last item in array with javascript code example
Example 1: js get last array element
const array = [1, 2, 3, 4]
const lastArrayElement = array[array.length - 1]
Example 2: how to select last element in a array
if (loc_array[loc_array.length - 1] === 'index.html') {
// do something
} else {
// something else karunakar
}