Skip to content

Instantly share code, notes, and snippets.

@davidep87
Last active January 31, 2017 13:06
Show Gist options
  • Save davidep87/f5a677c3857d79f2bf1420c89d896798 to your computer and use it in GitHub Desktop.
Save davidep87/f5a677c3857d79f2bf1420c89d896798 to your computer and use it in GitHub Desktop.
function pickReplace(obj, objPick){
let no = {};
for(let k of objPick){
if(k in obj){
no[k] = obj[k];
}
}
return no;
}
let obj = user; // Example of object
let objPick = ['id', 'firstName', 'email']; // what we would like to pick from our obj
let entry = pickReplace(obj, objPick);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment