Searching Inside a String

Learn how to access the index of any word or a sub-string in the Array in JavaScript.

We'll cover the following

Locate string inside a string

Looking for particular values inside a string is a common task.

The indexOf() takes as a parameter the searched-for value. If that value is found inside the string, it returns the index of the first occurrence of the value. Otherwise, it returns -1.

Remember! The indexOf() function can take an additional argument too.

Get hands-on with 1200+ tech skills courses.