Thursday, May 26, 2011

JavaScript Variable/Function Scope - a Mystery: Part2

All this time I've lived with the impression that "public" methods (declared in a prototype) cannot access "private" members of constructor functions. Turns out that this is possible, as long as the "private" member is declared without var standing in front.


Compare it with this one:

No comments: