Email or username:

Password:

Forgot your password?
Axel Rauschmayer

#JavaScript: By default, array.flat() flattens up to depth 1.

> [ 'a', ['b'], [['c']], [[['d']]] ].flat()
[ 'a', 'b', [ 'c' ], [ [ 'd' ] ] ]

To go as deep as possible, pass it `Infinity`:

> [ 'a', ['b'], [['c']], [[['d']]] ].flat(Infinity)
[ 'a', 'b', 'c', 'd' ]

exploringjs.com/impatient-js/c

4 comments
Go Up