object - Deleting this in javascript -


this question has answer here:

i'm trying write js function , i'd add destroy() functionality it. code goes this:

 function jsfunc(obj)  {     var inputcontrol=function(){         //check input object special rules.         // i.e  obj.wait_time isn't defined, return false     }        if(!inputcontrol())     {         return false;     }     var do_some_operation=function()     {         //do     }     var destroy=function()     {         delete (this);     }   }  var obj={     wait_time:100,     //... } var xxx= new jsfunc(obj);  $('#button').click(function(){     xxx.destroy();   }) 

when click #button doesn't anything. tried search web, found solutions , tried did not work.

i tried these code destroy() function:

1.  this=null; 2. for(var in this) {    delete(this[i]); } 

when use 1 of these, destroys original function, soii cannot re-intantiate again. can me?

delete removing properties objects. people use remove properties global object, making deletes variables. don't think it's wanted.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -