String.startsWith() Starts with
Last updated: 2026-09-09
String.startsWith() Starts with
startsWith checks if the string starts with the given prefix.
| Category | Strings |
|---|---|
| ES version | ES2015 |
📝 Syntax
const flag = str.startsWith(prefix);
⚙️ Parameters
| prefix | The prefix to match, case-sensitive. |
|---|
Returns:A boolean.
Mutates the original:No (returns a new value)
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
true
false
💡 Tip startsWith and endsWith are a pair.
ℹ️ info position is where matching starts.
🌐 Browser support
| Browser | |||||
|---|---|---|---|---|---|
| String.startsWith() | ✓ v41 | ✓ v12 | ✓ v40 | ✓ v9 | ✓ v28 |
| Supported by all modern browsers | |||||
🏷️ Related Items
💡 Related Cases
More case studies coming soon — check back later.
📚 Related Tutorials
❓ FAQ
QIs startsWith case-sensitive?
AYes — use toLowerCase first.
QstartsWith vs regex?
AstartsWith for plain prefixes; regex for complex.
QDoes startsWith mutate?
ANo — pure query returning a boolean.