find last occurrence of character in string javascript code example
Example 1: javascript string get last two character
var member = "my name is Mate";
var last2 = member.slice(-2);
alert(last2);
Example 2: js last index of
const str = "Users/Edit/12345";
let idx = str.lastIndexOf("/");
idx = str.lastIndexOf("x");
idx = str.lastIndexOf("Edit")
idx = str.lastIndexOf("edit")
idx = str.lastIndexOf("s");
idx = str.lastIndexOf("s", 3);
Example 3: find the last occurrence of a character in a string javascript
str.lastIndexOf(searchValue[, fromIndex])