> That's how the for-in loop works, no idea why. 

for in loops go backwards because they compile to reverse loops which
are MUCH faster than forward loops.  For more detailed information on
this subject, check out the Flasm page.

http://flasm.sourceforge.net/#optas


Here are the fastest loops:

// Pre-decrement (--a) is faster than post-decrement (a--)
// and subtraction (- (-1)) is faster than addition (+1)
// This can be SECONDS faster than any for loop

var a = 100;
while (--a -(-1)) {}


// Second fastest

var a = 100;
while (a--) {}


// Here's the fastest for loop.  Note the crazy syntax:

for (var i = myArray.length; --i -(-1); ) {}


_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to