I have the following code below, but one problem. I want to access a variable from inside the function clslevel() named the_id, from the calling anonymous function. I tried this.the_id but it returns undefined.
function clslevel(id){
var the_id = id;
this.methodOne=function(param){
param();
return this;
};
this.methodTwo=function(param){
param();
return this;
};
}
function level(id){
return new clslevel(id);
}
level("myButton")
.methodOne(
function(){
console.log("methodOne called.");
// how can I access the variable 'the_id' in clslevel() from here?
}
)
.methodTwo(
function(){
console.log("methodTwo called");
}
)
thank you in advance!