String.endsWith method
String › endsWith
Official
Checks if the string ends with a specific substring.Signature:
endsWith(searchString: string, endPosition?: number | undefined): booleanParameters:
| Parameter | Type | Description |
|---|---|---|
| searchString | string | The substring to check for. |
| endPosition? | number | undefined | The position to end checking at. |
Returns: boolean — true if the string ends with the substring, false otherwise.
Remarks:
The original version had different argument names. See bug:https://forum.obsidian.md/t/bug-string-endwith-definition/98103. Example:
console.log('foo'.endsWith('oo')); // trueconsole.log('foo'.endsWith('fo')); // falseconsole.log('foo'.endsWith('foo', 2)); // falseconsole.log('foo'.endsWith('fo', 2)); // true