Reputation: 17303
The following structure
function SomeObject() {}
SomeObject.prototype.repeatWhat = function() {
setInterval(this.what, 1);
}
SomeObject.prototype.what = function() {
console.log("what?");
}
Produces only a single "what?"
in the console, why isn't it just running perpetually?
I call it like so
var someInstance = new SomeObject();
someInstance.what();
Upvotes: 0
Views: 46
Reputation: 2879
You aren't calling repeatWhat
in your code
var someInstance = new SomeObject();
someInstance.what();
someInstance.repeatWhat(); //I've added this
Upvotes: 2