Re: [Proto-Scripty] Re: local variables for for() array iteration
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 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... }); 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 rudirak...@gmail.com 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 prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. 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 prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Re: local variables for for() array iteration
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 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 t...@crowdersoftware.comwrote: @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 rudirak...@gmail.com 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 prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com . 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 prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.