A
abozhilov
E262-3 edition
11.4.1 The delete Operator
The production UnaryExpression : delete UnaryExpression is evaluated
as follows:
1. Evaluate UnaryExpression.
2. If Type(Result(1)) is not Reference, return true.
3. Call GetBase(Result(1)).
4. Call GetPropertyName(Result(1)).
5. Call the [[Delete]] method on Result(3), providing Result(4) as the
property name to delete.
6. Return Result(5).
I don't understand something about the delete operator.
If i have code like this.
window.foo = {};
var bar = foo;
delete window.foo;
alert(window.foo);
alert(bar);
1. Attach `foo` property to Global Object. assigned to `foo` reference
to `object`.
2. Copy reference from `foo` and assigned to bar.
3. delete window.foo, will be delete `foo` property. Just delete
reference to `object`.
4. Results will be `undefined`. Logical.
5. Results will be `[object Object]`
What do `delete` operator when i delete reference? Just marked
`object` to garbage collection, if doesn't have any other reference to
that `object` in any scope? In my case created object from that line:
window.foo = {};
That object will be deleting after reload my page. Not reference, i
talk about `object`. Because i have reference to that object in global
scope:
var bar = foo;
If i have code like this:
window.foo = {};
(function()
{
var bar = foo;
delete window.foo;
alert(window.foo);
alert(bar);
})();
When `object` will be deleting? The last reference to that object is
in the anonymous function scope. I thing after executing anonymous
function that object will be delete. Because `bar` variable have local
scope.
Thanks.
11.4.1 The delete Operator
The production UnaryExpression : delete UnaryExpression is evaluated
as follows:
1. Evaluate UnaryExpression.
2. If Type(Result(1)) is not Reference, return true.
3. Call GetBase(Result(1)).
4. Call GetPropertyName(Result(1)).
5. Call the [[Delete]] method on Result(3), providing Result(4) as the
property name to delete.
6. Return Result(5).
I don't understand something about the delete operator.
If i have code like this.
window.foo = {};
var bar = foo;
delete window.foo;
alert(window.foo);
alert(bar);
1. Attach `foo` property to Global Object. assigned to `foo` reference
to `object`.
2. Copy reference from `foo` and assigned to bar.
3. delete window.foo, will be delete `foo` property. Just delete
reference to `object`.
4. Results will be `undefined`. Logical.
5. Results will be `[object Object]`
What do `delete` operator when i delete reference? Just marked
`object` to garbage collection, if doesn't have any other reference to
that `object` in any scope? In my case created object from that line:
window.foo = {};
That object will be deleting after reload my page. Not reference, i
talk about `object`. Because i have reference to that object in global
scope:
var bar = foo;
If i have code like this:
window.foo = {};
(function()
{
var bar = foo;
delete window.foo;
alert(window.foo);
alert(bar);
})();
When `object` will be deleting? The last reference to that object is
in the anonymous function scope. I thing after executing anonymous
function that object will be delete. Because `bar` variable have local
scope.
Thanks.