JavaScript LastIndexOf string function returns the index of the specified string pattern from the provided string. JavaScript LastIndexOf function starts traversing the string from right side of the provided string and returns the last occurrence of the specified string pattern. Try the sample below: