Skip to content

Instantly share code, notes, and snippets.

@gotoweb
Forked from eddieajau/extractColumn.js
Created February 16, 2016 05:53
Show Gist options
  • Save gotoweb/fb982dd441c7728ee5ad to your computer and use it in GitHub Desktop.
Save gotoweb/fb982dd441c7728ee5ad to your computer and use it in GitHub Desktop.
Extract a column from an array of JavaScript objects.
function extractColumn(arr, column) {
function reduction(previousValue, currentValue) {
previousValue.push(currentValue[column]);
return previousValue;
}
return arr.reduce(reduction, []);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment