DontDelete property of javascript objects

According to the EcmaScript specification, some properties of objects cannot be deleted due to the internal parameter DontDelete. For instance:

var y = 5

should not be deleted. But from what I was able to verify, this.

Here's the link in the Mozilla Developer Center: https://developer.mozilla.org/en/JavaScript/Reference/Operators/Special/delete

Any ideas why this doesn't work the way it should be?

+5
source share
3 answers

, . DontDelete ECMA (262, . 5). , [Configurable]? delete , :

var y=5, 
    z = {y:5};
delete y;
delete z.y;
alert(y);   //=> 5
alert(z.y); //=> undefined

, SO , T.J. Crowder.

0

ES5 17:

CreateMutableBinding (N, D) . N . D .

10.5

  • VariableDeclaration VariableDeclarationNoIn d , [...] II. envs SetMutableBinding , dn, undefined, , .

, . , obejct, . , ...

+1
var y = 5
alert(delete (y));

Show false . Then it cannot be deleted.

0
source

All Articles