get object value from array javascript code example
Example 1: array objects to array of one property
let result = objArray.map(a => a.foo);
Example 2: return an object from an array javascript
myArray.find(item => item.isAstronaut)
Example 3: get all id from array of objects javascript
function getFields(input, field) {
var output = [];
for (var i=0; i < input.length ; ++i)
output.push(input[i][field]);
return output;
}
var result = getFields(objArray, "foo"); // returns [ 1, 3, 5 ]