Javascript examples for String:includes
The includes() method returns true if the string contains the specified characters, and false if not.
The includes() method is case sensitive.
Parameter | Description |
---|---|
searchvalue | Required. The string to search for |
start | Optional. Default 0. At which position to start the search |
A Boolean. Returns true if the string contains the value, otherwise it returns false
The following code shows how to Check if a string includes "world":
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {// w w w. ja v a 2 s.co m var str = "Hello world world world"; var n = str.includes("world", 12); document.getElementById("demo").innerHTML = n; } </script> </body> </html>