JavaScript String includes() method
determines if a string includes a specified value

includes() method determines if a string includes a specified value.

syntax

includes(searchString, start)

searchString A string to be searched for within the specified string. It cannot be a regex.

All values that are not regexes are coerced to strings.

start (optional). The start position within the string at which to begin searching for searchString. Defaults to 0.

includes() method returns true if a string includes a specified string.

includes() method returns false if a string does NOT contain a specified string.

includes() method throws TypeError if searchString is a regex.

includes() method is case sensitive.

String to be searched for (searchString) must be a string and cannot be a regex.

You can use a start index (position) where the searchString is expected to start from. Default start position is 0.

If start index (position) is less than zero, the method behaves as if start position were 0.

syntax 1 description
determine if myString includes entered searchString
myString.includes(searchString)
syntax 2 description
determine if myString includes entered searchString from start position
myString.includes(searchString, start)