Last active
December 14, 2015 21:39
-
-
Save valeriu/5152614 to your computer and use it in GitHub Desktop.
Reports the zero-based index position of the last occurrence of a specified Unicode character or string within this instance. The method returns -1 if the character or string is not found in this instance.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>lastIndexOf</title> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
var str = "abcdefabcdef" | |
document.write(str.lastIndexOf('a')+"<br />"); | |
//abcdefabcdef (string) | |
// × (finded) | |
// × (start) <-- | |
document.write(str.lastIndexOf('a',2)+"<br />"); | |
//abcdefabcdef (string) | |
//× (finded) | |
// × (start) <-- | |
document.write(str.lastIndexOf('a',10)+"<br />"); | |
//abcdefabcdef (string) | |
// × (finded) | |
// × (start) <-- | |
document.write(str.lastIndexOf('a',0)+"<br />"); | |
//abcdefabcdef (string) | |
//× (finded) | |
//× (start) <-- | |
document.write(str.lastIndexOf('C',0)+"<br />"); | |
//abcdefabcdef (string) | |
// (not found) | |
// × (start) <-- | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment