Learning JavaScript/jsPerf.com

Comma seperated IDs or $.fn.add passing quickExpr

 * http://jsperf.com/comma-seperated-ids-or-fn-add-passing-quickexpr

Unless the query is rerouted to a native browser API, using .add will always be faster since those strings will pass quickExpr and not initiate the Sizzle selector engine at all.

However with more browsers going to support the native API (document.querySelectorAll), eventually one comma seperated list followed by 1 query to the browser's API will be faster.

In the test results the browsers having document.querySelectorAll show the first test is faster, in other browsers (most of them as of writing) the second will be faster.

--Krinkle 09:53, 22 May 2011 (UTC)

Performance impact of accessing deep level object members and/or length property in a loop

 * http://jsperf.com/performance-impact-of-accessing-length-in-for-loop

Often in code we see constructions like this: or even:

The reason is because this way the part of the for-syntax that is is evaluated after every loop (the middle part between the two semi-colons ) does not have to look up the length of the array, instead it is cached in a local variable (using a combined  statement in the initializing part of the for-syntax).

For numbers see the jsPerf

--Krinkle 23:35, 12 August 2011 (UTC)