title: Which way is better in Javascript, string concatenation or with array?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/7299010/why-is-string-concatenation-faster-than-array-join">Why is string concatenation faster than array join?</a>  </p>
  </blockquote>
  
  
  
  <p>Usually we need to generate html contents dynamically in Javascript.
  Two ways like below:</p>
  
  <pre><code>var s = "", a = [];
  for (var i = 0, l = data.length; i &lt; l; i++) {
    s += "&lt;a href='#'&gt;" + data[i].name + "&lt;/a&gt;";
    a[i] = "&lt;a href='#'&gt;" + data[i].name + "&lt;/a&gt;";
  }
  container.innerHTML = s; // or
  container.innerHTML = a.join("");
  </code></pre>
  
  <p>Which way is better? Mainly foucus on performance, or the differences can be ignored.</p>