> 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/collection/includes.md).

# \_.includes（检查值是否在数组/对象/字符串中）

**语法：**

```javascript
_.includes(collection, value, [fromIndex=0])
```

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

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

**描述：**

检查`value`(值) 是否在`collection`(集合) 中。如果`collection`(集合)是一个字符串，那么检查`value`（值，子字符串） 是否在字符串中， 否则使用[`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)做等值比较。 如果指定`fromIndex`是负数，那么从`collection`(集合) 的结尾开始检索。

**开始版本：**&#x30;.1.0

**参数：**

* `collection (Array|Object|string)`: 要检索的集合。
* `value (*)`: 要检索的值。
* `[fromIndex=0] (number)`: 要检索的 索引位置。

**返回值：**

* `(boolean)`: 如果找到 value 返回 true， 否则返回 false。

**例子：**

```javascript
_.includes([1, 2, 3], 1);
// => true

_.includes([1, 2, 3], 1, 2);
// => false

_.includes({ 'a': 1, 'b': 2 }, 1);
// => true

_.includes('abcd', 'bc');
// => true
```

注意：

```javascript
_.includes({ 'a': 1, 'b': 2 }, { 'a': 1}
// => false
_.includes({ 'a': 1, 'b': 2 }, 1);
// => true
```
