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:

'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:

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

Download my free JavaScript Beginner's Handbook!


Check out my in-depth, practical Web Development Courses!

(all 50% off with the coupon code POSITIVEVIBRATIONS)

⤴️⤴️⤴️

And signup to my upcoming JavaScript Bootcamp!

⤴️⤴️⤴️