String.endsWith() Ends with
Last updated: 2026-09-09
String.endsWith() Ends with
endsWith checks if the string ends with the given suffix.
| Category | Strings |
|---|---|
| ES version | ES2015 |
📝 Syntax
const flag = str.endsWith(suffix);
⚙️ Parameters
| suffix | The suffix 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
true
💡 Tip toLowerCase before extension checks.
ℹ️ info A pair with startsWith for prefixes vs suffixes.
🌐 Browser support
| Browser | |||||
|---|---|---|---|---|---|
| String.endsWith() | ✓ 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
QendsWith vs regex?
AendsWith for simple suffixes; regex for complex patterns.
QCase-sensitive?
AYes — use toLowerCase first.
QWhat's the second arg?
ATruncates the string to that length before matching.