Skip to content

Instantly share code, notes, and snippets.

@sentience
Forked from lstebner/_.remove.js
Last active April 21, 2020 20:47
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sentience/f8bd15cdd37165ca40e0 to your computer and use it in GitHub Desktop.
Save sentience/f8bd15cdd37165ca40e0 to your computer and use it in GitHub Desktop.
Underscore.js mixing to remove one or more keys from an object
// remove key from object
_.mixin({
remove: function(obj, keys){
return _.chain([keys]).flatten().reduce(function(obj, key){
delete obj[key];
return obj;
}, obj).value();
}
});
# remove key(s) from object
_.mixin
remove: (obj, keys) ->
_.chain([keys]).flatten().reduce(
(obj, key) ->
delete obj[key]; obj
, obj).value()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment