Courses / JavaScript
28. String.prototype.indexOf()
Returns the index of the first occurrence of a specified value in a string.
1 min read Chapter 28 of 99
JavaScript
String.prototype.indexOf()
`indexOf` helps you find where a specific substring appears in a string.
"I need to know if a word is in a sentence and where it starts."
`String.prototype.indexOf()` returns the index of the first occurrence of a specified substring in a string, or -1 if not found.
"I need to know if a word is in a sentence and where it starts."
`String.prototype.indexOf()` returns the index of the first occurrence of a specified substring in a string, or -1 if not found.