Hi Mike, Thanks very much for your reply and the information. What I'm hoping to be able to do is to provide a plug-in API for my jQuery plug-in which will allow the new API functions to be able to access the private methods which I use. I know you can't force something to expose private methods (or they wouldn't be private!) but what I was wondering was if it was possible to allow access to those methods if you know that you want to do this (without making everything public)...
Here is the basic idea for what I want to do in code (and with the eval/toString method I described above): fnApi = function () { console.log( 'API function is running with required scope: '+iPi ); } fnContainer = function () { var iPi=3.141592; this.fnApi = eval( '('+ fnApi.toString()+')' ); }; var oContainer = new fnContainer(); oContainer.fnApi(); Many thanks, Allan On Feb 14, 5:53 pm, "Michael Geary" <m...@mg.to> wrote: > JavaScript uses lexical scoping: The scope chain for a function is > determined solely by the location of the function definition in the source > code. > > Evaling the function's source code is a clever solution, and probably the > only way to do this. With eval() you're creating a new function from source > code that is treated as if it were in the location of the eval() call. > > Could you give a working example of how you'd actually use this? Maybe there > is a different way to approach the problem. > > -Mike