Instantiating A Class And Then Pass It To Setinterval
I've a crazy problem. I'm instantiating an object from a class. Then I want to pass a function from this object to the setInterval function. The whole code block is executed with a
Solution 1:
The workaround would be: wrap it using another function instead of calling method directly
functiondoKeyDown(e){
var instance = newClass(e.keyCode);
setInterval(function(){
instance.functionToBeExecuded()
}, 200);
}
This would give output many of these:
Class{functionToBeExecuded: function}
Post a Comment for "Instantiating A Class And Then Pass It To Setinterval"