Skip to content

Instantly share code, notes, and snippets.

@dncrht
Created January 29, 2016 07:34
Show Gist options
  • Save dncrht/099de77fbfeba740c5f2 to your computer and use it in GitHub Desktop.
Save dncrht/099de77fbfeba740c5f2 to your computer and use it in GitHub Desktop.
JS map and omit
_ = {
map: function(hash, lambda) {
return Object.keys(hash).map(function(key) {
var value = hash[key];
return lambda(value, key);
});
},
omit: function(hash, unwanted) {
var tmp = {};
Object.keys(hash).map(function(key) {
var value = hash[key];
if (key !== unwanted) {
tmp[key] = value;
}
});
return tmp;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment