convert HTML collection into array

Benchmark created on


Preparation HTML

<html>
<body>
<form>
<div>
<input type="text" name="username" value="username"/>
<input type="password" name="password" value"password"/>
</div>
<input type="button" value="login"/>
</form>
</body>
</html>

Setup

var objs=document.forms[0].elements;
    objsArray=Array.prototype.slice.call(objs);

Test runner

Ready to run.

Testing in
TestOps/sec
HTML collection
for(var i=0;i<objs.length;i++){
 alert(objs[i].value);
}
ready
convert HTML collection into Array
for(var i=0;i<objsArray.length;i++){
 alert(objsArray[i].value);
}
ready

Revisions

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