Reverse vs Looping Backwards (v4)

Revision 4 of this benchmark created on


Description

This is a test to see if using the reverse() method on an array and then looping forwards is faster than just looping backwards on the array.

Preparation HTML

<script>
  var arr0 = new Array(10000);
  
  
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Reverse Method 1
arr0.reverse();
for(var i = arr0.length; i--;)
{
arr0[i];
}
ready
Reverse Method 2
for(var i = arr0.length; i--;)
{
arr0[i];
}
ready
Looping Backwards 1
var i=arr0.length;
while(i--)
{
arr0[i];
}
 
ready
Looping Backwards 2
for(var i=0, l = arr0.length; i < l; i++)
{
arr0[i];
}
ready

Revisions

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