JavaScript arrays are getting two new methods. `Array.prototype.flat()` returns a new array with all sub-array elements concatenated into it recursively up to the specified depth. The sub-array elements become members of the new array. `Array.prototype.flatMap()` first maps each element using a mapping function, then flattens the result into a new array. This method is functionally equivalent to a map followed by a flatten of depth 1.

Documentation

Specification

Specification link


Specification being incubated in a Community Group

Status in Chromium

Blink>JavaScript>Language


Enabled by default (tracking bug)

Consensus & Standardization

After a feature ships in Chrome, the values listed here are not guaranteed to be up to date.

  • No signal
  • No signal
  • No signal
  • Positive

Owner

Last updated on 2020-11-09