> For the complete documentation index, see [llms.txt](https://lodash.shujuwajue.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lodash.shujuwajue.com/string/endswith.md).

# \_.endsWith（检测结尾字符串）

**语法：**

```javascript
_.endsWith([string=''], [target], [position=string.length])
```

**源代码链接：**[source](https://github.com/lodash/lodash/blob/4.17.10/lodash.js#L14208)

**npm包链接：**[npm package](https://www.npmjs.com/package/lodash.endswith)

**描述：**

检查字符串`string`是否以给定的`target`字符串结尾。

**开始版本：**&#x33;.0.0

**参数：**

* `[string=''] (string)`: 要检索的字符串。
* `[target] (string)`: 要检索字符。
* `[position=string.length] (number)`: 检索的位置。 **返回值：**
* `(boolean)`: 如果字符串string以target字符串结尾，那么返回 true，否则返回 false。

**例子：**

```javascript
_.endsWith('abc', 'c');
// => true

_.endsWith('abc', 'b');
// => false

_.endsWith('abc', 'b', 2);
// => true
```
