Standard built-ins
String.prototype.endsWith()
Tests a literal suffix before the given end boundary, or the entire length if omitted.
Formal Syntax & Structure
javascript syntaxjavascript
text.endsWith(searchString, [endPosition])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| searchString | String | Literal sequence to locate. |
| endPosition | Number | End boundary of the checked prefix. |
Return Value
Boolean
Whether the suffix matches.
Working Example
Example Snippetjavascript
console.log("a.txt".endsWith(".txt"));