Transitioning to strict mode

Claus Reinke claus.reinke at
Thu Feb 21 12:37:07 PST 2013

> For the ES5 semantics of the interaction of the global scope and the global
> object, how could you make this a static error? What would you statically
> test? Would you statically reject the following program, where
> <someExpression> is itself just some valid expression computing a value
> (that might be the string "foo")? Note that "this" below is the global
> object, since it occurs at top level in a program.
> "use strict";
> this[<someExpression>] = 8;
> console.log(foo);

My first reaction would be to reject the 3rd line statically. We can't
hope to check dynamic scoping statically, but we could enforce
safety of the language parts that look like they invoke static scoping.

Either declaring 'foo' or logging 'this["foo"]' would be available as
workarounds. So I don't see this example as an argument for a
runtime error on the 3rd line.


More information about the es-discuss mailing list