1function getFields(input, field) {
2 var output = [];
3 for (var i=0; i < input.length ; ++i)
4 output.push(input[i][field]);
5 return output;
6}
7
8var result = getFields(objArray, "foo"); // returns [ 1, 3, 5 ]
9
1//Getting One Value from an Array of Items or sum of array
2var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
3var total = numbers.reduce(function(total, current) {
4 return total + current;
5}, 0);
6
7console.log(total);