[Proto-Scripty] Re: local variables for for() array iteration

2011-01-20 Thread RobG
On Jan 20, 4:50 pm, Ran Berenfeld berenfeld...@gmail.com wrote: Thank you for the advise. one more / last question to clarify. In one of the articles about javascript scopes I read that using var inside a class constructor actually creates a private member of the class. is it true ? No.

[Proto-Scripty] Re: local variables for for() array iteration

2011-01-19 Thread T.J. Crowder
Hi, Yes, you should use a `var` statement -- specifically, two of them. With your functions as quoted, you're falling prey to the Horror of Implicit Globals[1], meaning that both your `A` and `B` functions are using the *same* variable (a global variable), and so of course `B` is interfering with

[Proto-Scripty] Re: local variables for for() array iteration

2011-01-19 Thread T.J. Crowder
@Rüdiger: And last but not least, if this is a prototype mailing list you should of course use prototype, so your loops would look like this: Whether I'm using Prototype or not, I don't need to create a function and incur the overhead of a function call on every iteration (not to mention the

Re: [Proto-Scripty] Re: local variables for for() array iteration

2011-01-19 Thread Rüdiger Kaatz
Hmm, it' is the prototype way of doing it. I suppose it has to do with writing beautiful code, but that might be a matter of taste. Some like it and some don't :-) On Wed, Jan 19, 2011 at 11:59 PM, T.J. Crowder t...@crowdersoftware.com wrote: @Rüdiger: And last but not least, if this is a

[Proto-Scripty] Re: local variables for for() array iteration

2011-01-19 Thread RobG
On Jan 19, 11:31 pm, Ran Berenfeld berenfeld...@gmail.com wrote: Hello all sorry for this stupid question, but all these talks about the *this pointer and the variable scope in js got me confused. A function's this keyword has nothing to do with scope. support I have 2 functions, one

Re: [Proto-Scripty] Re: local variables for for() array iteration

2011-01-19 Thread Ran Berenfeld
Thank you for the advise. one more / last question to clarify. In one of the articles about javascript scopes I read that using var inside a class constructor actually creates a private member of the class. is it true ? if this is true, then should I avoid using for (var i=0;iarr.length;i++) like