MCPcopy
hub / github.com/lodash/lodash / includes

Function includes

lodash.js:9530–9541  ·  view source on GitHub ↗

* Checks if `value` is in `collection`. If `collection` is a string, it's * checked for a substring of `value`, otherwise * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * is used for equality comparisons. If `fromIndex` is negative, it's used as

(collection, value, fromIndex, guard)

Source from the content-addressed store, hash-verified

9528 * // => true
9529 */
9530 function includes(collection, value, fromIndex, guard) {
9531 collection = isArrayLike(collection) ? collection : values(collection);
9532 fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
9533
9534 var length = collection.length;
9535 if (fromIndex < 0) {
9536 fromIndex = nativeMax(length + fromIndex, 0);
9537 }
9538 return isString(collection)
9539 ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
9540 : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
9541 }
9542
9543 /**
9544 * Invokes the method at `path` of each element in `collection`, returning

Callers 4

baseDifferenceFunction · 0.85
baseIntersectionFunction · 0.85
baseUniqFunction · 0.85
test.jsFile · 0.85

Calls 5

isArrayLikeFunction · 0.85
valuesFunction · 0.85
toIntegerFunction · 0.85
isStringFunction · 0.85
baseIndexOfFunction · 0.85

Tested by

no test coverage detected