Behavior of `eval` in non strict mode.

Andrea Giammarchi andrea.giammarchi at
Fri Jan 10 19:05:37 PST 2014

I've learned it the hard way ... when in doubt, see what Firefox does ...
usually that's the meant standard behavior.

I really wish JavaScript was a Test Driven developing programming language
... the amount of fragmentation for every single little thing apparently
never tested against meant specs is often too damn high!

Best Regards

On Fri, Jan 10, 2014 at 5:50 PM, Benjamin (Inglor) Gruenbaum <
inglor at> wrote:

> Thanks, this clarifies things. I'll update the answer on SO to reflect the
> findings.
> On Thu, Jan 9, 2014 at 3:54 AM, André Bargull <andre.bargull at>wrote:
>> Thanks for the reply.
>>> I'd actually expect `undefined` because function declarations does not
>>> return anything. Converting it to a function expression kind of misses
>>> the
>>> point since those are well... expressions :)
>>> I've tried looking in all the relevant places in the spec but still
>>> couldn't unambiguously figure out which browser is 'correct'.
>> There are a few edge cases in reference resolution which are not
>> correctly implemented in most browsers. Your example is basically the same
>> as test case 2 from
>> The relevant section in the specification is "12.13.4 Runtime Semantics:
>> Evaluation": The left hand side of an assignment is always evaluated before
>> the right hand side. This includes resolving and remembering the reference
>> information for an identifier reference. In this case the identifier
>> reference resolves to a binding on the global object, so assignment must be
>> performed on the global, even if a (direct) eval expression introduces new
>> bindings with the same name in the current scope.
>> - André
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list