Subj : Scoping question To : netscape.public.mozilla.jseng From : r.knight@zoodigitalgroup.com (Rich K) Date : Tue Jan 13 2004 08:17 am Hi, We've succesfully managed to embed and run JavaScript in our app using spidermonkey so far, I've hit a bit of a stumbling block tho. Does anyone know if the following is possible somehow? If I've got the following bit of script defined 'globally' function MyFunc() { SomeGlobalVar=10; } then this script associated with one object in our application function MyOtherFunc() { Var = SomeGlobalVar * 2; } and this script associated with another object in the application function MyOtherFunc() { Var = SomeGlobalVar * 3; } I'd like each of the final two bits of script to be able to use the first global function and variable, but only see it's own version of MyOtherFunc and Var. I don't want two totally separate sets of script - I only want to define and run MyFunc once, since it may do something very time consuming. Hope that makes some sense :) Thanks! Rich. .