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.
value
collection
SameValueZero
fromIndex
The collection to inspect.
The value to search for.
Optional
The index to search from. @param- {Object} [guard] Enables use as an iteratee for methods like reduce.
reduce
Returns true if value is found, else false.
true
false
5.12.0
includes([1, 2, 3], 1);// => trueincludes([1, 2, 3], 1, 2);// => falseincludes({ 'a': 1, 'b': 2 }, 1);// => trueincludes('abcd', 'bc');// => true Copy
includes([1, 2, 3], 1);// => trueincludes([1, 2, 3], 1, 2);// => falseincludes({ 'a': 1, 'b': 2 }, 1);// => trueincludes('abcd', 'bc');// => true
Checks if
value
is incollection
. Ifcollection
is a string, it's checked for a substring ofvalue
, otherwiseSameValueZero
is used for equality comparisons. IffromIndex
is negative, it's used as the offset from the end ofcollection
.