Function includes

  • 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.

    Type Parameters

    • T = any

    Parameters

    • collection: ArrayLike<T> | Record<string, T>

      The collection to inspect.

    • value: T

      The value to search for.

    • OptionalfromIndex: number

      The index to search from. @param- {Object} [guard] Enables use as an iteratee for methods like reduce.

    • Optionalguard: any

    Returns boolean

    Returns true if value is found, else false.

    5.12.0

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

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

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

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