Image

Instance Name

I am having some trouble getting the instance name of a class.

I have a class (this is just an example)

class = function()
{
    this.instanceName = ???
    this.x = 50;
    
    this.start = function()
    {
        this.interval= window.setInterval(this.instanceName + '.moveIndicator()', this.x);
    }
    
    this.stop = function()
    {
	window.clearInterval(this.timer);
    }
}


My issue is that short of passing in the instance name I dont know how to dynamically determine it. I am sure that this is possible.

I could also be approaching this incorrectly. Essentially the issue is that when the methods are fired off clearInterval has no idea what "this" refers to.