array length vs saved variable

Benchmark created on


Description

Compare array.length calls vs saving the length in a variable

Setup

var testArray = new Array(100000);

Test runner

Ready to run.

Testing in
TestOps/sec
array.length
for (var i = 0; i < testArray.length; i++) {
  var percent = i / testArray.length;
}
ready
length variable
var length = testArray.length;
for (var i = 0; i < length; i++) {
  var percent = i / length;
}
ready

Revisions

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