Some time ago in an “Optimize jQuery/JavaScript” type of article I read that array joins are faster than string concatenations. It seems that this is not true! Although I didn’t just believe the article blindly. I ran a few quick tests and indeed seemed to get results that supported that conclusion. This however, was a while back, it’s possible I screwed up the tests, or maybe browsers started doing things differently.
I’ve already verified, more recently, that this is not the case but I wanted to setup another test using the jsPerf website that allows one to create public tests that aggregate results from all the testers. They also show the results in a nice chart that gives me a big picture view of the test results. In any case, I created a test with 4 cases to see what kind of an advantage string append has over array join. As well as compare different ways to append strings. The test is available at http://jsperf.com/append-string-vs-join-array Read more »
