I am trying to set an interval in my JS file and call a function from within it. However, I get an error when trying to call a function from inside of the interval. Here is my code:
Note: I trigger _testFunction()
to start the chain at the top of the document.
_testFunction3: function(){
console.log("Test Function 3 Hit");
},
_testFunction2: function(){
console.log("Test Function 2 Hit");
},
_testFunction: function(){
console.log("Test Function 1 Hit");
this._testFunction2();
var timer = null;
timer = setInterval(function(){
this._testFunction3();
}, 1000);
},
Expected result:
Console logging following:
- Test Function 1 Hit
- Test Function 2 Hit
- Test Function 3 Hit (every 1 second)
Actual result:
Console logging following:
- Test Function 1 Hit
- Test Function 2 Hit
- Uncaught TypeError: this._testFunction3 is not a function
I have tried many things and just can't get it to work...