Checks if an array contains a given value or an array of values.
contains(['apple', 'banana', 'cherry'], 'banana'))// => truecontains(['one', 'two', 'four'], ['two', 'one'])// => truecontains(['apple', 'banana', 'cherry'], 'orange'))// => falsecontains([1, 2, 3], 4)// => falsecontains([1, "hello", 3], 4)// => falsecontains("not an array")// => false Copy
contains(['apple', 'banana', 'cherry'], 'banana'))// => truecontains(['one', 'two', 'four'], ['two', 'one'])// => truecontains(['apple', 'banana', 'cherry'], 'orange'))// => falsecontains([1, 2, 3], 4)// => falsecontains([1, "hello", 3], 4)// => falsecontains("not an array")// => false
The type of the elements in the input array.
The array to check.
The value or array of values to check for.
A boolean value indicating whether the array contains the value(s).
Generated using TypeDoc v0.24.7
Checks if an array contains a given value or an array of values.
Example