What's the easiest way to get object keys from array of objects. Ex.
var obj = [{"foo": 1, "bar": 2}, {"foo": 10, "bar": 20, "baz": 30}]
// ['foo', 'bar', 'baz']
What's the easiest way to get object keys from array of objects. Ex.
var obj = [{"foo": 1, "bar": 2}, {"foo": 10, "bar": 20, "baz": 30}]
// ['foo', 'bar', 'baz']
You can map everything to a single array with reduce:
obj.reduce((acc, curr) => acc.concact(Object.keys(curr)), [])
This gives you:
['foo', 'bar', 'foo', 'bar', 'baz']