Array.flatMap() Playground

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