innerhtml testing vs Array#concat

Edit on GitHub

jsinnerhtml

Setup

<li id="list">l</li>
var len = 4;

Tests

  • innerhtml testing

    for (var i = 0; i < len; i++) {
    document.getElementById('list').innerHTML += "<div>test</div>";
    }
  • Array#concat

    var html = [];
    for (var i = 0; i < len; i++) {
    html.push("<div>test</div>");
    }
    document.getElementById('list').innerHTML += html.join('');