First of all, I generally like the idea of simplyfiying the process of building up arrays from logic.
However, I do have a few concerns:
for
, async
and others are fundamental statements of the language, now they are suddenly used as expressions . The only way I can think of, for this to work in the way you propose it, is to introduce a whole new set of syntax, that redefines these keywords.
That's a lot of new syntax, just to support little new functionality ... I mean, there is already:
const result = [...(function*() {
for (year of years) if (year > 2000 && year < 2010) yield year;
})()];