Null iterable in for-of?

Erik Arvidsson erik.arvidsson at
Thu Jun 12 14:36:39 PDT 2014

Somehow I missed when we decided to allow null/undefined as the iterable
value in for-of loops.

The following test passes using the spec algorithms:

var c = 0;
for (var x of null) {
assert.equal(c, 0);

However, if we get a null value here we are most likely just masking an
user bug.

I assume the justification is that for-in allows null here? However, for-of
is new syntax and we have the chance to get this right this time around.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list