Animations
API
Arrays
Async
Basics
Challenges
Classes
Console
Dates
Debugging
DOM Elements
DOM Methods
DOM Properties
Event Listeners
Flow Control
Forms
Functions
Global Functions
JSON
Keywords
Libraries (3rd party)
Math
Modules
Objects
Snippets
String
Types
Widgets
Window Object
The lastIndexOf()
method returns the index of the last occurrence of a specified text in a string. If it is NOT found,
it will return a -1.
let str = "Please locate where 'locate' occurs!";
let pos = str.lastIndexOf("locate");
document.getElementById("demo1").innerHTML = "The position of the last 'locate' is: " + pos + ".";