Skip to main content

includes

_.includes(value, collection) # Ⓢ [Ⓣ][1] Ⓝ

Checks if value is in collection. If collection is a string, it's



checked for a substring of value, otherwise



SameValueZero



is used for equality comparisons. If fromIndex is negative, it's used as



the offset from the end of collection.

Since​

0.1.0

Arguments​

  1. value (*): The value to search for.
  2. collection (Array|Object|string): The collection to inspect.

Returns​

(boolean): Returns true if value is found, else false.

Example​

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

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

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

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