February 2018
Intermediate to advanced
298 pages
8h 22m
English
The startsWith() method is used to find whether a string begins with the characters of another string, returning true or false as appropriate. Here is an example to demonstrate this:
const str = "Hi, I am a JS Developer";console.log(str.startsWith('Hi, I am')); //Output "true"
It takes an optional second parameter representing the position in the string at which to begin searching. Here is an example to demonstrate this:
const str = "Hi, I am a JS Developer";console.log(str.startsWith('JS Developer', 11)); //Output "true"
Read now
Unlock full access