How can I efficiently remove all elements from an array that match the values of subsequent unknown arguments? Here's my current approach:
function destroyer(arr) {
var arrayOfArgs = [];
var newArray = [];
for (var i = 0; i < arguments.length; i++) {
newArray = arr.filter(function (value) {
return value !== arguments[i + 1];
});
}
return newArray;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);