JS Coding Questions Logo
JS Coding Questions
#134💼 Interview💻 Code

How do you check if a string starts with another string

Advertisement

728x90

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,

javascript
1"Good morning".startsWith("Good"); // true
2  "Good morning".startsWith("morning"); // false

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 50

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
134of476
How do you check if a string starts with another string | JSCodingQuestions.com