Skip to content

Instantly share code, notes, and snippets.

@pandauxstudio
Created July 12, 2017 05:38
Show Gist options
  • Save pandauxstudio/6eaba5910fdfada75fa3f1f4c7cf6f2e to your computer and use it in GitHub Desktop.
Save pandauxstudio/6eaba5910fdfada75fa3f1f4c7cf6f2e to your computer and use it in GitHub Desktop.
Eliminate certain properties within an array of objects
// source: https://jsfiddle.net/pandauxstudio/k1nq92sk/8/
// create dummy awards object array.
const awards = [
{
awardNumber: "1",
awardStatus: "CURRENT",
awardType: "CERT",
awardVersionNumber: 1,
caseId: "C11111"
},
{
awardNumber: "2",
awardStatus: "DRAFT",
awardType: "CERT",
awardVersionNumber: 1,
caseId: "C11111"
},
];
console.log('// awards');
console.log(awards);
// iterate through awards array and print selective properties.
const awardsSimplified = awards.map(function(award){
const awardSimplified = _.pick(award, ['awardNumber', 'awardVersionNumber']);
return awardSimplified;
});
console.log('// awards simplified');
console.log(awardsSimplified);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment