object - Deleting this in javascript -
this question has answer here:
- destroy 'this' javascript? 1 answer
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
Post a Comment