Javascript ES2019 tip #1
1 min read

Javascript ES2019 tip #1

Flatten your multi-dimensional arrays using ES2019's [].flat()

Chrome Version 72 rolled out new exciting ES10 features for developer to use in browser. Flatten your multi-dimensional arrays using ES2019's [].flat()

const arr = ['a', 'b', ['c', 'd']];
const flattened = arr.flat();

console.log(flattened);    // => ["a", "b", "c", "d"]