Find the index of a substring inside a string

suggest change

The .indexOf method returns the index of a substring inside another string (if exists, or -1 if otherwise)

'Hellow World'.indexOf('Wor');    // 7

.indexOf also accepts an additional numeric argument that indicates on what index should the function start looking

"harr dee harr dee harr".indexOf("dee", 10); // 14

You should note that .indexOf is case sensitive

'Hellow World'.indexOf('WOR');    // -1

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents