To check whether multiple values exist within a JavaScript array, we use the every
and includes
methods.
For instance, we write
const success = arrayA.every((val) => arrayB.includes(val));
to call arrayA.every
with a callback that checks if every val
in arrayA
is in “arrayBwith
includes`.
If the condition is met for all elements in arrayA
, then true
is return
.