Subj : Re: variables and scopes To : Stuart From : Igor Bukanov Date : Thu Sep 23 2004 03:40 pm Stuart wrote: .... > > I have an application scope, a document scope and an anonymous scope > (anonymous prototype is the document and the document prototype is the > application). > > On the application scope I ran (note I did not use: var rootCounter = 8): > > context.evaluateString(appScope, "rootCounter = 8", "test", 1, null); > > Then from the anonymous scope I run: > > context.evaluateString(anonScope, "rootCounter = rootCounter + 1", "test", > 1, null); > > Then from the anonymous scope I get the value of: > [Note: to get the value I used > Object resultObject = ecmaContext.evaluateString(anonScope, "rootCounter", > "test", 1, null); > resultString = ecmaContext.toString(resultObject);] > > rootCounter (this comes out as 9) > -and- > application.rootCounter (this comes out as 8) > > Why would rootCounter and application.rootCounter have different values? > Are they not the same? There is alot of other stuff going on in my program > so it may be something else that I am doing...but if you have any ideas > please let me know. In JS assign always set property at the head of prototype chain thus rootCounter = rootCounter + 1 will set rootCounter in the anonymous scope and not in your document/application scope. Regards, Igor .