Get Array Of All Property In Object Array

[Solved] Get Array Of All Property In Object Array | Swift - Code Explorer | yomemimo.com
Question : get array of all property in object array

Answered by : gubo97000

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]

Source : | Last Update : Tue, 27 Apr 21

Answers related to get array of all property in object array

Code Explorer Popular Question For Swift