'How to destroy an object on Javascript from a class

Ok I have this object from class

//Classes for actors ingame
//Runtime actors 
class Actor 
{
    //public ActorHealth = 100; 

    constructor(name, x, y, team, mainTexture, InternalTexture, ActorHealth, ActorState ) 
    {
        this.name = name;
        this.x = x; 
        this.y = y;
        this.team = team; //Team 1 Players/hero  Team 2 Enemies
        this.mainTexture = mainTexture;//"BloodForWebGladiators1.png"; 
        this.InternalTexture=new Image();
        this.InternalTexture.setAttribute("src", this.mainTexture);  
        this.ActorHealth = 100;     
        this.ActorState = "Alive"; //"Alive" is alive, "Dead" is dead
    }
 
    //Set location for character sprite
    setLocation(px, py) 
    {
        this.x = px; 
        this.y = py;
    }
    
    //WIP
    ActorTakeDamage(DamageAmount)
    {
        this.ActorHealth -= DamageAmount; 
        console.log("FROM Actor taking damage now health is"+this.ActorHealth ); 
        
        if( this.ActorHealth <= 0 && this.ActorState == "Alive" ) 
        {
            this.ActorDie(); 
        }
        
        spawnActor('PlayerBloodParticle', this.x, this.y, 1, "BloodForWebGladiators1.png", "Particle");   //actor 0  
    }
  
    ActorDie()
    {
        console.log("FROM Actor DYING is"+this.ActorHealth );   
        //this.DestroySelf()
        this.ActorSetActorState("Dead");
        this.InternalTexture.setAttribute("src", "GWArcherLoadingArrowDead.png");
        setInterval(this.DestroySelf.bind(this),3000.0); //Find a way to clear the timer
    }
  
    ActorSetActorState(NewActorState)
    {
        this.ActorState = NewActorState; 
        
    }
  
    ActorTick()
    {
        //TestFunction(); 
        if( DoesCollideXYWithXY(this.x, this.y, player_x, player_y, 2, 2 ) )
        {
            this.CollideOverlap();
        }
    }  
  
    CollideOverlap()
    {

    }
 
    DestroySelf()
    {
        DestroySpecificActorOfTheWorld(this); 
    } 
}

As you can see it gets destroyed, all it does its remove self from specific actor from array, but how to actually erase it totally from the memory?????????



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source