flatten object arrays code example
Example 1: flatten nested array javascript
const arr2 = [1, 2, [3, 4, [5, 6]]];
arr2.flat();
Example 2: flat function javascript
const arr1 = [1, 2, [3, 4]];
arr1.flat();
// [1, 2, 3, 4]
const arr2 = [1, 2, [3, 4, [5, 6]]];
arr2.flat();
const arr1 = [1, 2, [3, 4]];
arr1.flat();
// [1, 2, 3, 4]