got an issue with accessing an object parameter in a function of the object if I pass this function as parameter and then call it.I.e. in below code I had expected that this.radius == 100
is always true. Hover in test3
below it is not if beforehand I pass test3
as parameter. Any idea why and how I can access the variable there?
Cheers Tom
Test = function ( ) {
var self = this;
this.radius = 100;
this.test1();
}
Test.prototype.test1 = function() {
console.log("test1 - this"+this.radius);// this.radius==100
console.log("test1 - self"+self.radius);// self.radius==undefined
this.test2(this.test3);
}
Test.prototype.test2 = function (func){
console.log("test2- this"+this.radius);// this.radius==100
console.log("test2- self"+self.radius);// self.radius==undefined
func();// calling the function passed as parameter
}
Test.prototype.test3 = function (){
console.log("test3- this"+this.radius);// this.radius==undefined
console.log("test3- self"+self.radius);// self.radius==undefined
}