Hi there, there are not stupid questions of course. They could be a bit more prototype-related though... All you should have to do is use var in order to make a variable "local" to the function it is declared in. In your example that would be: for(var i=0;i<array_b_length;i++)
On Wed, Jan 19, 2011 at 2:31 PM, Ran Berenfeld <[email protected]> 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. > support I have 2 functions, one calling the other inside array iteration. > can they both > use the same local variable for array index ? > should I use a "var" statement ? > > for example : > > > function B() > { > for(i=0;i<array_b_length;i++) > { > ... > } > } > > function A() > { > for(i=0;i<array_a.length;i++) > { > B() > ... > } > } > > Thanks > Ran > > -- > You received this message because you are subscribed to the Google Groups > "Prototype & script.aculo.us" group. > To post to this group, send email to > [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/prototype-scriptaculous?hl=en. > -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
