Toggle navigation
Genres
Frontend (2)
JavaScript (6)
Database (2)
Linux Server (3)
Web Apps (4)
Misc (4)
Search
List
New Tutorials
Last Modified Tutorials
</>
Code examples
code
smiko
javascript
basic
035stringmethods_indexOf.js
035stringmethods_indexOf.js
/** * String methods: indexOf * Return position of substring inside string. */ var str, pos1, pos2; str = "simple example of simple string"; pos1 = str.indexOf('sim'); pos2 = str.indexOf('Sim'); //indexOf is case sensitive console.log(pos1); // 0 console.log(pos2); // -1
Reload page
Preview
W3C validation
Edit Code
JS Console