Emptying a select box (v4)

Revision 4 of this benchmark created on


Preparation HTML

<select id="box">
</select>
<script>
  var box = document.getElementById("box");
  var n = 2000;
</script>

Setup

var s = [];
    for (var i = 1; i <= 1000; ++i) {
      s += "<option>Option " + i + "</option>\n";
    }
    box.innerHTML = s;

Test runner

Ready to run.

Testing in
TestOps/sec
box.innerHTML = ""
box.innerHTML = "";
ready
box.options.length = 0
box.options.length = 0;
ready
box.removeChild
while (box.options.length) {
  box.removeChild(box.options[0]);
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.