String concatenation versus array.join() in JavaScript
Tuesday, January 19th, 2010To answer a question on StackOverflow, I made an experiment which actually qualifies for a separate blog post.
So, I compared the speed of str1+str2 concatenation and array.push(str1, str2).join() methods. The code I used was quite simple:
var iIterations =800000; var d1 = (new Date()).valueOf(); str1 = “”; for (var i = 0; i<iIterations; i++) str1 = str1 + Math.random().toString(); var [...]
