During my walk to work today I tried, and failed to rationalize the double iteration I had put in place; so I switched to the forward iteration and figure compilers will decide what's best for them.
On Mar 14, 6:48 am, Jason Mulligan <[email protected]> wrote: > I prefer the use of .reverse() with the countdown, since that can be > compiler optimized and still out perform the forward iteration in > older browsers. It's difference should only come into play when > dealing with arrays >50k > > On Mar 14, 12:32 am, RobG <[email protected]> wrote: > > > > > > > > > On Mar 14, 1:34 pm, RobG <[email protected]> wrote: > > > > On Mar 13, 9:31 am, Jason Mulligan <[email protected]> > > > wrote: > > > > var instances = [], > > > > i = arg.length; > > > > > while (i--) { > > > > instances.push($(arg[i], nodelist)); > > > > } > > > > return instances; > > > The use of a decrementing counter reverses the order of returned > > elements, so given (id1, id2) it returns (element2, element1). To > > return elemetns in the order requested, consider: > > > for (var i=0, iLen=arg.length; i<iLen; i++) { > > instances.push(...); > > } > > > -- > > Rob -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
