Javascript examples for String:startsWith
The startsWith() method checks if a string begins with given characters.
The startsWith() 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 starts with the value, otherwise it returns false
check where if the string starts with the specified value.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*w ww.java2 s . c om*/ var str = "The following code shows how to "; var n = str.startsWith("The", 6); document.getElementById("demo").innerHTML = n; } </script> </body> </html>