0

Here is a class:

function Interface(){
    this.listOfFunctions = {
       clearHistory: this.clearHistory
       //some other functions
    }
    this.history = [];
    this.test = "test";
}

Interface.prototype.clearHistory = function(){ //Clears the history

    //make sure that it has the correct 'this' context
    console.log(this.test);
    this.history = [];

}

Interface.prototype.runSomething = {

     //run the function
     this.listOfFunctions.clearHistory();
}

How would I run "clearHistory" inside "runSomething" whilst keeping the context of this?

Eidolon
  • 309
  • 3
  • 12

0 Answers0