includes() / indexOf()
Finds the presence/position of a part.
Syntax
text.includes(part) · text.indexOf(part)
Description
includes returns true/false. indexOf gives the position (-1 if not found).
Example
Loading editor…
Expected output
true 3
When to use?
Searching, checking whether a word appears in the text.