Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const array = [1, 2, [3, 4, [5, 6]]];
- function deep_flatten(array){
- return array.reduce(function(flat,toFlatten){
- return flat.concat(Array.isArray(toFlatten)? deep_flatten(toFlatten) : toFlatten);
- },[] )
- }
- console.log(deep_flatten(array));
Add Comment
Please, Sign In to add comment