Looking for a function in underscore.js that will take 2 arrays and return a new array of unique values? Something like _without
_.without([0, 1, 3, 9], [1, 3])
_.without.apply(_, [arr1].concat(arr2))
[[0, 1, 3, 9]].concat([1, 3])
is [[0, 1, 3, 9], 1, 3]
;
_.without.apply(_, [[0, 1, 3, 9], 1, 3])
is _.without([0, 1, 3, 9], 1, 3)
You've got a perfectly good _.without
method. So just convert an array into a list of values you can pass into a function. This is the purpose of Function.prototype.apply