flat and flatMap, and the depth argument

Flattening an array was [].concat(...arrays), which works for one level and reads like a trick rather than an operation.

[[1, 2], [3, [4, 5]]].flat();          // [1, 2, 3, [4, 5]]
[[1, 2], [3, [4, 5]]].flat(2);         // [1, 2, 3, 4, 5]
[[1, [2, [3]]]].flat(Infinity);        // [1, 2, 3]

// flatMap is map-then-flat(1), and it is the useful one
orders.flatMap(o => o.lines);

// which also gives you a filter-and-map in one pass
rows.flatMap(r => r.valid ? [transform(r)] : []);

The default depth of one catches people who expect a deep flatten, and Infinity is the explicit form rather than a large number. flatMap returning an empty array to drop an element is a genuinely useful idiom that replaces a chained filter and map with one traversal — and unlike the chained version it can also emit more than one element per input, which is what makes it more than a shorthand.