On Fri, Jan 7, 2011 at 10:38 PM, Angus Croll <[email protected]> wrote:

> Just wanted to add a couple of things to Dmitry's answer.
>
> There are at least 2 differences between variables and properties in
> the global scope:
>
> 1) Property references are deletable but by default variables are not.
>
> window.foo = 42;
> delete foo; //true
> foo; //undefined
>
> var foo = 42;
> delete foo; //false
> foo; //42
>
> This is because by default the internal [[Configurable]] property of
> variables is set to false (in ES5 terms) or the [[DontDelete]]
> property is true (in ES3).
>
>
By the way, in strict ES5 (which will be default mode of ES6, Harmony) there
is one subtle case with deleting bindings. It's not possible to delete a
binding (e.g. a global property) _regardless_ its [[Enumerable]] flag if the
base of a reference is an environment record.

E.g.

// both foo and bar are configurable

this.foo = 1
this.bar = 2

delete this.foo // true, OK
delete bar // Error!

Dmitry.

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to