PDA

View Full Version : String Concatination



ravipati_raja
29 Mar 2007, 4:28 AM
In the source code i came across a couple of string concatinations using +.
It would be nice if these are changed to using the array.join() as we gain much better performace.

brian.moeskau
29 Mar 2007, 4:43 AM
Actually, this is a common misperception. Array.join() is always more efficient AFTER a certain point, but for a few values, the concatenation operator is actually faster (and more convenient of course):

http://blogs.msdn.com/ie/archive/2006/11/16/ie-javascript-performance-recommendations-part-2-javascript-code-inefficiencies.aspx


When the number of values being concatenated is small enough the concatenation operator still wins. The cross-over point is not entirely deterministic, but exists somewhere in the neighborhood of 7-13 values. For larger strings the count may be much smaller.