They could have also implemented flat in terms of flatMap: flatMap(x => x)
I personally feel flatMap is a much more used method than flat, so if you want to remove one, I would remove flat.
I personally feel flatMap is a much more used method than flat, so if you want to remove one, I would remove flat.
Flat can flatten any level of nesting (it just defaults to 1), so would be difficult to implement in terms of flatMap.
function flatten(x, n=1) {
return n > 0 ? x.flatmap(y => flatten(y, n-1))
: x;
}