[Javascript] accessing nested functions
Edwin Martin
edwin at bitstorm.org
Sat Jul 7 02:34:41 CDT 2007
Pedro Mpa wrote:
> I'm having some trouble accessing nested functions, like in the following
> example, how can I access function c ?
>
> function a(){
> this.vara = "";
>
> this.b = function(){
> this.varb = "";
>
> this.c = function(){
> this.varc = "";
> alert('something');
> }
> }
> }
>
> Tried using:
>
> test = new a();
> test.b.c();
>
c is only assigned to b if you execute b. So thiw works:
function a(){
this.vara = "";
this.b = new function(){
this.varb = "";
this.c = function(){
this.varc = "";
alert('something');
}
}
}
test = new a();
test.b.c();
The only change is in the line this.b = new function(){
>
>> test.b.c() Is not a function.
>>
>
> Is there a limit for nesting functions in JS ?
>
I don't believe there is.
Edwin Martin
More information about the Javascript
mailing list