Is it faster to concatenate a string or an array in JavaScript? : <p>Which is faster?</p>

<pre><code>var str = '';
for(var i=0; i&lt;1000; i++) {
    str += i;
}
</code></pre>

<p>or</p>

<pre><code>var arr = [];
for(var i=0; i&lt;1000; i++) {
    arr.push(i);
}
var str = arr.join(''); 
</code></pre>

<p>I ask because I have written a CSS parser which works really well, but is very slow for larger stylesheets (understandably). I am trying to find ways of making it faster, I wondered if this would make a difference. Thanks in advance!</p>
