I would like to use lodash function chaining in order to iterate over an array of objects, and push each of the object values into a new array.
I could use a nested forEach for that purpose but I understand there are better ways.
I want to turn this array from:
[ {a: 'foo', b: 'bar'}, {a: 'baz', b: 'foo2'}, {a: 'bar2', b: 'baz2'} ] into the following result:
[ 'foo','bar','baz', 'foo2', 'bar2', 'baz2' ] Can anyone please help?
_.flatMap(Object.values)?Array.prototype.flatMapshould be in the next version of JavaScript so you would just write:myObjects.flatMap(Object.values);