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;i<arr.length;i++) like statements inside a class constructor ? because then "i" would become a class member, and then using "var i" inside class function is not safe. am I right ? Ran On Thu, Jan 20, 2011 at 12:59 AM, T.J. Crowder <[email protected]>wrote: > @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 complications around `this`) just to loop through an > array. People are free to do that if they like, but it's not remotely > necessary and it's certainly not always appropriate. There's nothing > wrong with a nice, simple `for` loop. > > Just my two cents. > -- > T.J. Crowder > Independent Software Engineer > tj / crowder software / com > www / crowder software / com > > On Jan 19, 3:18 pm, Rüdiger Kaatz <[email protected]> wrote: > > 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: > > > > $A(array_b_length).each(function(arrayElement) { > > // do something with the element... > > > > > > > > > > > > > > > > }); > > -- > 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]<prototype-scriptaculous%[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.
