Array Comprehensions

Tab Atkins Jr. jackalmage at
Mon Feb 6 21:41:06 UTC 2017

On Mon, Feb 6, 2017 at 9:47 AM, Gil Tayar <gil at> wrote:
> Forgive me if I'm wrong, but the double-for comprehension (e.g. [for (i of
> numbers) for (j of letters) i + j]) can't be easily expressed in JS because
> there's no flatMap.

Correct. (Which is why we need to add it.)

Aside: double-for in array comprehensions is only Pythonic in very
simple cases; it's usually quite hard to read.  The functional version
is somewhat better imo:

numbers.flatMap(i => => i+j));


More information about the es-discuss mailing list