I tried something like:
function Objeto(){
this.del = function(){
delete this;
}
}
var a = new Objeto();
a.del();
But the a
variable is still existing
I know the method mentioned in @bfavaretto's response, but for the code I'm working on I can not 'raise a level' in the variable structure to execute this delete
, or obj = null
;
Here's where I want to use this:
Bullet.prototype.step = function() {
for (var i = 0; i < mobs.length; i++){
if ((this.x >= mobs[i].x && this.x <= mobs[i].x + mobs[i].size) && (this.y >= mobs[i].y && this.y <= mobs[i].y + mobs[i].size)){
mobs[i].getHit(this.damage);
delete this;
}
}
};
Or the complete reference: link