Created
April 26, 2020 00:11
-
-
Save fal-works/9f880a7b3f347eccf3af8b688da5a545 to your computer and use it in GitHub Desktop.
str.lastIndexOf(searchString, null) returns -1
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
// Node v13.12.0 | |
const str = "abcde"; | |
const searchString = "c"; | |
const indices = [ | |
str.indexOf(searchString), // 2 | |
str.indexOf(searchString, null), // 2 | |
str.lastIndexOf(searchString), // 2 | |
str.lastIndexOf(searchString, null) // -1 | |
]; | |
indices.forEach((n, i) => console.log(`case${i}: ${n}`)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment