Skip to content

Instantly share code, notes, and snippets.

@justinobney
Created January 16, 2015 20:52
Show Gist options
  • Save justinobney/85ab58b8bef334384671 to your computer and use it in GitHub Desktop.
Save justinobney/85ab58b8bef334384671 to your computer and use it in GitHub Desktop.
function pick(collection, properties){
[].map.call(collection, function(val, key){
var result = {};
properties.forEach(copyProperty);
return result;
function copyProperty(propName){ result[propName] = val[propName]; }
})
}
pick([{name:'justin', id:1}], ['name']);
// produces => [{name:'justin'}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment