links: [[JS MOC]]
---
### Description
This method lets you determine whether or not a string ends with another string. This method is case-sensitive.
### Syntax
```js
str.endsWith(searchString [, length])
```
**Parameters:**
`searchString`
The characters to be searched for at the end of `str`
`length` (Optional)
If provided, it is used as the length of `str`. Defaults to `str.length`
### Examples
```js
let str = 'To be, or not to be, that is the question.'
console.log(str.endsWith('question.')) //true
console.log(str.endsWith('to be')) // false
console.log(str.endsWith('to be', 19)) // true
```
---
tags: #javascript , #string
[source](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith)