Assigning to globals in strict mode

Brendan Eich brendan at mozilla.org
Mon Oct 18 11:08:23 PDT 2010


On Oct 18, 2010, at 10:38 AM, Dmitry A. Soshnikov wrote:

> On 18.10.2010 21:13, Jeff Walden wrote:
>> On 10/18/2010 10:09 AM, Oliver Hunt wrote:
>>> Am I missing something important?  Does delete fail for all properties on the global object in strict mode?
>>> 
>>> Or does the behaviour of put in strict mode result in new properties on the global object always being configurable = false?
>> 
>> This doesn't have anything to do with configurability, I think -- you don't get far enough to know the binding is mutable.  It's simply that delete throws when provided an unqualified name (identifier), because such a name always evaluates to a Reference with an environment record as its base.
>> 
> 
> Hm... a good catch. Which I think is an err of the spec. I think that step 5 of the 11.4.1 was provided to mean exactly _variables_ (function declarations, args). I.e. do catch the case of trying to delete non-configurable thing. However, this 11.4.1 step 5 wrongly (?) grabs configurable properties which can be deleted. Thus, of course it occurs before we get analysis of the configurable attribute. Possibly a small errata is needed.

It's not an error. It is intentional, according to a grand plan that culminates in Harmony with no global object on the scope chain. It's a kind of future-proofing.

If you *really* want to delete a global property, say so: delete window.foo, or in global code delete this.foo.

/be


More information about the es5-discuss mailing list