Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get array of all property in object array

objArray = [ { foo: 1, bar: 2}, { foo: 3, bar: 4}, { foo: 5, bar: 6} ];
let result = objArray.map(a => a.foo); //[1,3,5]
//OR
let result = objArray.map(({ foo }) => foo) //[1,3,5]
 
PREVIOUS NEXT
Tagged: #array #property #object #array
ADD COMMENT
Topic
Name
6+4 =