js get first and last element of array code example
Example 1: find last item in an array JS
if (loc_array[loc_array.length - 1] === 'index.html') {
// do something
} else {
// something else
}
Example 2: how to find last element in array
int [] y={1,2,3,4,5};
int c=(n.length-1);