0 votes
in JavaScript by
How do you check if a string starts with another string?

1 Answer

0 votes
by

You can use ECMAScript 6's String.prototype.startsWith() method to check if a string starts with another string or not. But it is not yet supported in all browsers. Let's see an example to see this usage,

"Good morning".startsWith("Good"); // true
"Good morning".startsWith("morning"); // false
...