Array.prototype.subtract >= 0.1.0
Purpose
Get the values from the first array that are not in the second array
Syntax
Array#subtract
(
ArrayarrFunctioncast_function
);
Parameters
arr
- The array to test agains
cast_function
- Function to use to cast values
Return values
Array
New array
Examples
Return all the values of the first array that are not in the second array
var a = [0,1,2,47,99,100],
b = [2,47,55,96,200];
a.subtract(b);
>>> [0, 1, 99, 100]
b.subtract(a);
>>> [55, 96, 200]
Remove a single value
var a = [0,1,2,47,99,100];
a.subtract(100);
>>> [0,1,2,47,99]
Comments