last substring in javascript code example
Example 1: javascript get last character in string
var hello = "Hello World";
var lastCharOfHello=hello.slice(-1);
Example 2: javascript last character of string
var lastChar = myString[myString.length -1];
Example 3: lastindexof() javascript
'canal'.lastIndexOf('a');
'canal'.lastIndexOf('a', 2);
'canal'.lastIndexOf('a', 0);
'canal'.lastIndexOf('x');
'canal'.lastIndexOf('c', -5);
'canal'.lastIndexOf('c', 0);
'canal'.lastIndexOf('');
'canal'.lastIndexOf('', 2);
Example 4: lastindexof js
string.lastIndexOf("subString")