Skip to content

Instantly share code, notes, and snippets.

@fortruce
Created April 23, 2015 16:45
Show Gist options
  • Save fortruce/7389f05780f5a50d168c to your computer and use it in GitHub Desktop.
Save fortruce/7389f05780f5a50d168c to your computer and use it in GitHub Desktop.
Javascript filter properties out of an object.
function without(o) {
var props = Array.prototype.slice.call(arguments, 1);
var r = {};
for (var k in o) {
if (o.hasOwnProperty(k) && props.indexOf(k) === -1)
r[k] = o[k];
}
return r;
}
without({'keep': 1, 'remove': true}, 'remove');
// {'keep': 1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment