get last elements of arr js code example
Example 1: get last item in array js
if (loc_array[loc_array.length - 1] === 'index.html') {
// do something
} else {
// something else
}
Example 2: get last element in array in javascript
arr.slice(-1)[0]