coderef

Array flat() and flatMap()Baseline · Widely available

The flat() and flatMap() methods for arrays creates a new array such that each nested array item is concatenated into it.

Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Jan 15, 2020. Widely available since Jul 15, 2022.

Browser support

DesktopChrome
1–68Not supported
69+Supportedsince Sep 4, 2018
Current: 155
Edge
12–18Not supported
79+Supportedsince Jan 15, 2020
Current: 154
Firefox
1–61Not supported
62+Supportedsince Sep 5, 2018
Current: 157
Safari
1–11.1Not supported
12+Supportedsince Sep 17, 2018
Current: 27
MobileChrome Android
18–68Not supported
69+Supportedsince Sep 4, 2018
Current: 155
Firefox Android
4–61Not supported
62+Supportedsince Sep 5, 2018
Current: 157
Safari iOS
1–11.3Not supported
12+Supportedsince Sep 17, 2018
Current: 27

How to use

This feature is Baseline widely available — use it freely, no fallback needed.

Example

Full syntax and examples are on MDN: flat.

Feature detection

JS · check before using
if ("flat" in Array || ("prototype" in Array && "flat" in Array.prototype)) {
  // Array.flat is available
}

Sub-features

Support for each part of the feature (2). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
Array.flat69796212696212
Array.flatMap69796212696212