Null iterable in for-of?

Erik Arvidsson erik.arvidsson at gmail.com
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) {
  c++;
}
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: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140612/a41d35fd/attachment-0001.html>


More information about the es-discuss mailing list