JavaScript Array_flat Guide
Array flat and flatMap for flattening nested arrays and combining mapping with flattening. The guide walks through Array flat & flatMap. `arr.flat(depth)` — flatten nested arrays (default depth=1). `arr.flat(Infinity)` — fully flatten. `arr.flatMap(fn)` — map then flat one level. Example: `["hello", "world"].flatMap(s => s.split(""))` = ["h","e","l","l","o","w","o","r","l","d"]. flatMap is more efficient than map + flat. The guide is organized into 1 sections that build on each other, each pairing a prose explanation with runnable code. Related guides: Arrays, Strings, Numbers, Math, Date. This is one of 145 JavaScript guides on JS Reference — see the full list on the guides page. Practice what you learn in the JavaScript playground, and look up any unfamiliar term in the JavaScript glossary.