A train with crates on its roof: map puts each array whole into one wagon, flatMap unpacks one level so [] drops the item, map().flat() needs a throwaway…
The key idea
flatMap = map then flat(1), and [] drops
Try it in this playground
Run map, then flatMap, on splitting words map leaves crates (a nested array); flatMap unpacks them into one list of words.
Drop with [] A callback that returns [] adds no wagon: map and filter in one pass.
Try returning null null is not an array, so it goes in as one wagon. Compare it with [].
Unpack every level with flat() Use the flat() way with depth 2 or Infinity on a train of stacked crates.