Skip to main content
InterviewHubPRO
Section Overview
Q138

Question 138 of 536

Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)

26%
JavaScript & V8 Internals (536 Qs)•Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)

How do you check if a string starts with another string

mid LevelCode ExampleHTTP & REST APIs

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
  "Good morning".startsWith("Good"); // true
  "Good morning".startsWith("morning"); // false