Array.prototype.{flat,flatMap}

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

Editor's draft

Status in Chromium

Blink>JavaScript>Language


Enabled by default (tracking bug) in:

  • Chrome for desktop release 69
  • Chrome for Android release 69
  • Android WebView release 69
  • Opera release 56
  • Opera for Android release 56

Consensus & Standardization

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

  • No public signals
  • No public signals
  • No public signals
  • Positive

Owner

Last updated on 2018-07-19