Will `for (var a of null) {}` throw an error?

Glen Huang curvedmark at gmail.com
Mon Dec 22 05:06:18 PST 2014

Ideally it shouldn’t, because its twin `for (var a in null) {}` won’t.

But looking at step 8 in https://people.mozilla.org/~jorendorff/es6-draft.html#sec-runtime-semantics-forin-div-ofexpressionevaluation-abstract-operation <https://people.mozilla.org/~jorendorff/es6-draft.html#sec-runtime-semantics-forin-div-ofexpressionevaluation-abstract-operation>, when passing `null` to `GetIterator()`, it will throw a type error when the result of step 2 `CheckIterable(null)`, which is `undefind`, is called in step 3 in the algorithm for `GetIterator()`.

Did I miss something or the current spec does throw an error?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141222/b9a207da/attachment.html>

More information about the es-discuss mailing list