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?
, . DontDelete ECMA (262, . 5). , [Configurable]? delete , :
DontDelete
Configurable
delete
var y=5, z = {y:5}; delete y; delete z.y; alert(y); //=> 5 alert(z.y); //=> undefined
, SO , T.J. Crowder.
ES5 17:
CreateMutableBinding (N, D) . N . D .
10.5
VariableDeclaration VariableDeclarationNoIn d , [...] II. envs SetMutableBinding , dn, undefined, , .
, . , obejct, . , ...
var y = 5 alert(delete (y));
Show false . Then it cannot be deleted.