<span style="color:#a30500" class="tadv-color">lastIndexOf()</span> method in the string class.
Here is an example of the method – lastIndexOf().
<!DOCTYPE html> <html> <head> <title>JS: lastIndexOf() Method</title> <meta charset="utf-8"> </head> <body> <script> var animal = "elephant"; var out = animal.lastIndexOf('e'); console.log(out); //outputs = 2 </script> </body> </html>
In the above example, there are two occurrence of character ‘e’. The
<span style="color:#a30000" class="tadv-color">lastIndexOf()</span> method returns the index value of last occurrence of ‘e’ which is 2.