On Thu, Jun 9, 2011 at 4:05 AM, CodeJunkie <[email protected]> wrote:
>
> var evtMgr = new EventManager();
>
> and then turn around and do
>
> delete evtMgr;
>
> The object still exists.
Unlike C++, new and delete in JavaScript are not related to each other. The
keyword new constructs a new object. However, the keyword delete removes a
*property* from an object. The value named by the property will not
necessarily be garbage collected---there may be other references to it. The
value is normally not deallocated immediately in any case.
Properties introduced with 'var' are not deletable, so 'delete' correctly
does not delete the property.
> addition to this, any object or variable that i create by doing
> NS = {};
> delete NS;
>
> Works just fine and
>
> var foo = 20;
> delete foo;
>
> Does not remove the variable. Any thoughts on this?
>
>
Properties introduce with 'var' are not deletable. Most other properties
are.
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users