Matt_B
Well-Known Member
Right, this is driving me round the fecking bend. I have a JavaScript object and am trying to do the following concept:
I can do the following no problem:
var obj = new SomeObject(a,b);
obj.AnInternalFunctionToCall();
but when I try to call obj.AnotherFunction() it throws the error "this.AnInternalFunctionToCall is not a function"
Surely an internal method can call a method on itself? Any constructive help is appreciated!
Code:
function SomeObject(parameter1, parameter2){
this.par1 = parameter1;
this.par2 = parameter2;
this.AnInternalFunctionToCall(){
//do something
}
this.AnotherFunction(){
//do some stuff then try to call the other function declared
this.AnInternalFunctionToCall();
}
}
I can do the following no problem:
var obj = new SomeObject(a,b);
obj.AnInternalFunctionToCall();
but when I try to call obj.AnotherFunction() it throws the error "this.AnInternalFunctionToCall is not a function"
Surely an internal method can call a method on itself? Any constructive help is appreciated!