I have a JavaScript class
function MyClass() {
  MyClass.prototype.fooMethod = function () {
    // some logic goes here...
  }
  MyClass.prototype.fooMethod2 = function () {
    this.fooMethod();
  }
}
Everything works as expected when I call like this:
var m = MyClass();
m.fooMethod2();
However when I have this code called by setInterval I get an error: "Uncaught TypeError: Object [object DOMWindow] has no method 'fooMethod'"
var m = MyClass();
var intervalId = setInterval(m.fooMethod2, 100);
Is there any way I can use setInverval to call my method?
 
     
     
     
    