Last Index of JavaScript
Learn what is last index of function in javascript.
lastindexOf() Method:
It returns an index of the last occurrence of a given search element.
Syntax:
where:
searchElement:indicates element to be searchednumber : indicates index of the last occurence of the element to be searched
indexOf(search element:*):number
Ex:
var studNames=[“Ram”, “Ravi”, “Raju”,”Raghu”,”Gopal”,”Ravi”]
document.write(studNames.lastindexOf(“Ravi”); //5
See the above code, we have created an array with passing 6 value. The array index is starts from 0.
The lastindexof() function, which means it calculates last index