>>PS2: if JS engines keep improving at the current pace in a close future
calling methods will have very little overhead if compared to inline
code -
http://jsperf.com/function-call-overhead

Sadly the promise of 'near future' does not apply to those burdened
with supporting enterprises running on IE6 (thankfully not me anymore
but believe me they are still out there) I can attest that when IE is
slow every method call counts - and using regular for loops instead of
(library supplied) forEach was a significant help.

PS3: 50% slower than speed of sound is still fast, be pragmatic.

see above :-)

It's all about making informed judgements based on your own situation
- less about 'do this', 'don't do this' - which is why this group is
so great.

On Feb 19, 1:30 am, Miller Medeiros <[email protected]> wrote:
> I use reverse while loops always as I can (when the loop order doesn't make
> difference) since I find it clearer and easier to write (for loops are too
> verbose and cryptic in my opinion) and it usually performs better as well -
> you gain by caching array.length and also by looping backwards...
>
> var n = arr.length;
> while(n--){
>   console.log(arr[n]);
>
> }
>
> for live node collections caching the length property makes a huge
> difference as Peter said (or if the property is actually a getter), in other
> cases performance shouldn't make that much difference and in some cases
> there is not even a real gain in performance (specially on the newest
> engines) if you doubt it check this test:http://jsperf.com/fun-with-for-loops
>
> I find it a good practice to always cache the length not because of
> performance gains (that many times are null) but just so you get used to it
> and then later don't commit the mistake of not caching the length of a live
> collection (sometimes it isn't that clear you are dealing with a live
> collection and/or a getter).
>
> PS: backwards loops are usually faster since the comparison is against zero.
> PS2: if JS engines keep improving at the current pace in a close future
> calling methods will have very little overhead if compared to inline code 
> -http://jsperf.com/function-call-overhead
> PS3: 50% slower than speed of sound is still fast, be pragmatic.

-- 
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]

Reply via email to