javascript - How to delete an object from inside? -
i'd know how delete object inside, when object no longer used.
for example :
var myobject = function () { return { 'some': function() {...}, 'actions': function() {...}, 'destroy': function() { = null; // throws "referenceerror: invalid left-hand side in assignment" }, } } // doing so, able : var obj = new myobject(); obj.some(); // , when have finished : obj.destroy();
the reason behind can't destroy outside (the object created on "click" on dom element, destroyed when click somewhere else, scope of creation (in "onclick" method) not available want delete it.
how can ?
thanks help!
javascript doesn't work way. in fact, can't destroy objects whatsoever. 1 , thing can make sure not have references object make eligible garbage collection js runtime. if post more complete snippet can tell whether have memory leak or not, if have done corresponding .off
every .on
, set referencing variables null
, full extent of can , should in javascript.
Comments
Post a Comment