- This method is used to determine whether a string contains characters of a specified string or not.
- It returns a boolean value and is case sensitive.
includes() Function Explained
includes() method to determine whether a string contains characters of a specified string or not.
var str = "Hi, Mark!"; var inc = str.includes("Mark");
If you click the Try it Live button above, you may try changing the capitalization on the searched value and see for yourself how the result changes.
Theory is great, but we recommend digging deeper!
The second parameter is called start. It is optional and might not always be present in the parentheses. However, it is necessary if you want to define the place in the string to start the search process. In cases when the start argument is not included, the function automatically assumes it as 0 and starts at the beginning of the string.
|searchvalue||String to search for in the specified string. Required.|
|start||Position to start the search in the specified string. Optional. 0 by default|
The generated boolean object shows whether the string contained the characters you were searching to find. In other words, it answers whether searchvalue has been located in the string.
|Return Value:||A boolean value. True if string does contain value, false if it doesn't.|