# The String startsWith() method

> Learn how the JavaScript startsWith() method checks whether a string starts with a given substring, and how a second argument sets where to start checking.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2019-03-02 | Topics: [JavaScript](https://flaviocopes.com/tags/js/) | Canonical: https://flaviocopes.com/javascript-string-startswith/

Check if a string starts with the value of the string passed as parameter.

You can call `startsWith()` on any string, provide a substring, and check if the result returns `true` or `false`:

```js
'testing'.startsWith('test') //true
'going on testing'.startsWith('test') //false
```

This method accepts a second parameter, which lets you specify at which character you want to start checking:

```js
'testing'.startsWith('test', 2) //false
'going on testing'.startsWith('test', 9) //true
```
