direct vs indircect length access

Benchmark created on


Setup

const testArr = Array.from(Array(1000).keys());

let sum = 0;

Teardown

sum = 0;

Test runner

Ready to run.

Testing in
TestOps/sec
Direct length access
for (let i = 0; i < testArr.length; i++) {
	sum += i;
}
ready
Assign length to variable
for (let i = 0, len = testArr.length; i < len; i++) {
	sum += i;
}
ready

Revisions

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