Creation of the `arguments` object

Mathias Bynens mathias at qiwi.be
Wed Jul 4 08:11:12 PDT 2012


> The text is wrong. The order of steps in the normative part of the spec
> (Section 10.5, esp. step 6) makes clear that variable declarations are not
> taken into account (but parameters and function declarations are).

If I understand correctly, the `arguments` object is created in step
7, but then overwritten by the variable declaration in step 8.

So shouldn’t the first two examples in my mail (quoted below) get the
same result, then? Or are `var arguments;` and `var arguments =
undefined;` not both `VariableDeclaration`s?

On Wed, Jul 4, 2012 at 4:03 PM, Mathias Bynens <mathias at qiwi.be> wrote:
> Following that logic, I would expect the following code to return `"undefined"`:
>
>     function fn() {
>       var arguments;
>       return typeof arguments;
>     };
>     fn(); // "object"
>
> However, in all engines I tested this in, it returns `"object"` instead.
>
> On the other hand, this:
>
>     function fn() {
>       var arguments = undefined;
>       return typeof arguments;
>     };
>     fn(); // "undefined"
>
> …does return `"undefined"`.

Thanks for helping me understand!


More information about the es-discuss mailing list