includes source npm

_.includes(collection, target, [fromIndex=0])

Checks if target is in collection using SameValueZero for equality comparisons. If fromIndex is negative, it's used as the offset from the end of collection.

Arguments

  1. collection (Array|Object|string)

    The collection to search.

  2. target (*)

    The value to search for.

  3. [fromIndex=0] (number)

    The index to search from.

Returns (boolean)

Returns true if target is found, else false.

Example

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

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

_.includes({ 'user': 'fred', 'age': 40 }, 'fred');
// => true

_.includes('pebbles', 'eb');
// => true