• Checks if an array contains a given value or an array of values.

    Example

    contains(['apple', 'banana', 'cherry'], 'banana'))
    // => true

    contains(['one', 'two', 'four'], ['two', 'one'])
    // => true

    contains(['apple', 'banana', 'cherry'], 'orange'))
    // => false

    contains([1, 2, 3], 4)
    // => false

    contains([1, "hello", 3], 4)
    // => false

    contains("not an array")
    // => false

    Type Parameters

    • T extends string | number | boolean

      The type of the elements in the input array.

    Parameters

    • arr: T[]

      The array to check.

    • value: T | T[]

      The value or array of values to check for.

    Returns value is T | T[]

    A boolean value indicating whether the array contains the value(s).

Generated using TypeDoc v0.24.7