Returns true if all value in needles is contained in haystack.
needles
haystack
const a = ['apples','oranges','pears','mandarins'];const b = ['pears', 'apples'];contains(a, b); // Trueconst c = ['pears', 'bananas'];contains(a, b); // False ('bananas' does not exist in a) Copy
const a = ['apples','oranges','pears','mandarins'];const b = ['pears', 'apples'];contains(a, b); // Trueconst c = ['pears', 'bananas'];contains(a, b); // False ('bananas' does not exist in a)
If needles is empty, contains will return true.
contains
Array to search
Things to look for
Default comparer function is equiv to checking a === b. Use isEqualValueDefault to compare by value, via comparing JSON string representation.
a === b
Returns true if all value in
needles
is contained inhaystack
.If
needles
is empty,contains
will return true.