_.includes(collection, value, [fromIndex=0])
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
.
Since
0.1.0
Arguments
collection
(Array|Object|string): The collection to inspect.value
(*): The value to search for.[fromIndex=0]
(number): The index to search from.
Returns
(boolean): Returns true
if value
is found, else false
.
Example
_.includes([1, 2, 3], 1);// => true_.includes([1, 2, 3], 1, 2);// => false_.includes({ 'a': 1, 'b': 2 }, 1);// => true_.includes('abcd', 'bc');// => true
当前内容版权归 lodash.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 lodash.com .