I am having a JavaScript namespace say
A={
CA: function() {
this.B();
},
B: function() {
var test=\'test\';
var result=\'t1\';
C: functi
I think the problem is that when this.C()
is executed inside the function referred to by B
, this
refers to the object that contains B
, that is, object A
. (This assumes B()
is called within the context of A
)
The problem is, C
does not exist on the object A
, since it's defined within B
. If you want to call a local function C()
within B
, just use C()
.
EDIT:
Also, I'm not sure what you've posted is valid JavaScript. Specifically, B
should be defined this way, since you can't use the object:property syntax within a function.
B: function()
{
var test='test';
var result='t1';
var C = function()
{
this.test='test1';
return 'test1';
}
result=C();
return result;
}