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

Brendan Eich brendan at mozilla.org
Mon Dec 22 21:28:54 PST 2014


Your suggestion breaks Array.from and TypedArrayFrom.

/be

Gary Guo wrote:
> I suggest we can a little bit combine these steps:
>
> >CheckIterable (obj)
> >1. Let box be ToObject(obj).
> >2. ReturnIfAbrupt(box).
> >3. Return the result of calling the [[Get]] internal method of box
> passing @@iterator and obj as the arguments.
>
> If obj is `undefined` or `null`, the first step will fail and throw
> TypeError. If obj is primitive, it's boxed. If obj is an object, it is
> no-op in ToObject.


More information about the es-discuss mailing list