There is a class test
which has method addRecursively()
which has child function (is this the correct term btw?) childFunc()
which in turn calls addRecursively()
class Test {
addRecursively = function (i) {
i++;
childFunc();
function childFunc(){
if (i==5) {
console.log(i);
} else {
console.log("Not yet");
this.addRecursively(i); // Cannot read property 'addRecursively' of undefined
}
}
}
}
var testObj = new Test();
testObj.addRecursively(0);
How do I call the parent function without explicily addressing testObj
exemplar?