Skip to content

Instantly share code, notes, and snippets.

@abozhilov
Created August 12, 2013 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abozhilov/6209224 to your computer and use it in GitHub Desktop.
Save abozhilov/6209224 to your computer and use it in GitHub Desktop.
function pull(arr) {
var map = {},
res = [],
len = arr.length,
args = arguments;
for (var i = 1, argsLen = args.length; i < argsLen; i++) {
for (var j = len; j--;) {
if (arr[j] === args[i]) {
map[j] = true;
}
}
}
for (i = 0; i < len; i++) {
if (!map[i]) {
res.push(arr[i]);
}
}
return res;
}
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
console.log(pull(arr, 3, 2, 9, 4, 5));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment