Checks if all the elements in values
are included in arr
.
Array.prototype.every()
and Array.prototype.includes()
to check if all elements of values
are included in arr
.const includesAll = (arr, values) => values.every(v => arr.includes(v));
includesAll([1, 2, 3, 4], [1, 4]); // true
includesAll([1, 2, 3, 4], [1, 5]); // false
JavaScript, Array
Checks if at least one element of values
is included in arr
.
JavaScript, Array
Mutates the original array to filter out the values at the specified indexes. Returns the removed elements.
JavaScript, Array
Applies a function against an accumulator and each element in the array (from left to right), returning an array of successively reduced values.