Install: npm i tiny-array-flat-polyfill
import 'tiny-array-flat-polyfill';
const ARR = [1, [2, [3]], [[[4]]], 5]
ARR.flat() // [1, 2, [3], [[4]], 5]
ARR.flat(4) // [1, 2, 3, 4, 5]
[[1,2],[3,4]].flatMap(([x,y])=>x+y) // [3,7]
0.2.1
: fix handling of.flat(Infinity)
0.2.0
: only polyfill if.flat()
is not already available0.1.0
: initial release
See tests