I'm having trouble making a recursive call in this prototype method. The console prints:
count 1 (index):30
Uncaught ReferenceError: count is not defined
Instead, I need it to print:
count 1 (index):30
count 2 (index):30
...
var MyClass, mc;
MyClass = (function() {
function MyClass() {
this.count = 1;
}
MyClass.prototype.method = function() {
console.log("count", this.count);
this.count++;
if (count === 2) {
method();
}
};
return MyClass;
})();
mc = new MyClass();
mc.method();