I am trying to flatten an array with the following code, but when I use .flatMap()
I get the error:
Uncaught TypeError: flatMap mapper function is not callable
at Array.flatMap (<anonymous>)
const data = [
{ key1: 5, key3: 2 },
{ key1: 2, key3: 1 },
{ key1: 3, key3: 2 },
{ key2: 8 },
{ key1: 5, key3: 2 },
];
var allKeys = data.map(r => Object.keys(r))
// [
// [ 'key1', 'key3' ],
// [ 'key1', 'key3' ],
// [ 'key1', 'key3' ],
// [ 'key2' ],
// [ 'key1', 'key3' ]
// ]
allKeys.flatMap();