Javascript's for
statement returns undefined
, at least when I use it in Chromium's JS repl:
> for (i=0;i<1;i++);
: undefined
Therefore, I would expect the following statement to interpret thusly:
> a = for (i=0;i<1;i++);
: undefined
Instead I get
a = for (i=0;i<1;i++);
VM488:1 Uncaught SyntaxError: Unexpected token for
The only workaround I can think of is a = eval("for (i=0;i<1;i++);")
, which does work. However, as my question states, I want to do this without using eval
. Is it possible?