Answers for "javascript return object property from array"

0

map a property from array of objects javascript

var result = objArray.map(function(a) {return a.foo;});
Posted by: Guest on July-29-2020
0

javascript return object property from array

// ES5 compatible browsers
let result = objArray.map(a => a.foo);
OR
let result = objArray.map(({ foo }) => foo)

// FOR IE8 or older
var result = objArray.map(function(a) {return a.foo;});
Posted by: Guest on October-28-2021
0

Getting One Value from an Array of Items

//Getting One Value from an Array of Items or sum of array
var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
var total = numbers.reduce(function(total, current) {
    return total + current;
}, 0);

console.log(total);
Posted by: Guest on July-10-2020

Code answers related to "javascript return object property from array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language