So I guess my real question is, how do I "delete", remove, kill, etc. a native bound object? And yes I am aware of the GC and that it will clean up when there are no more references to said object ... and when it feels it needs to collect.
On Jun 8, 10:18 pm, "Lasse R.H. Nielsen" <[email protected]> wrote: > Kevin is absolutely correct. On top of that, you can actually check > whether a delete operations works - it is an expression that evaluates > to either true or false, depending on whether it manages to delete the > property. In this case it evaluates to false, which you can see by > doing, e.g., > print(delete foo); > in the shell. > > /Lasse > > > > > > > > > > On Thu, Jun 9, 2011 at 06:58, Kevin Millikin <[email protected]> wrote: > > 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. > > -- > Lasse R.H. Nielsen > [email protected] -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
