Run details:
Mozilla/5.0 (iPhone14,3; U; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Mobile/19A346 Safari/602.1
Mobile Safari 10
iOS 15.0
Mobile
11 months ago
Test name Executions per second
123456 123456.0 Ops/sec
123456 123456.0 Ops/sec
Script Preparation code:
AخA
 
var arr = [];
var count = 1000;
for(var i = 0; i<count; i++)
{
  arr.push(i);
}
Tests:
  • Cache length

     
    var arrLen = arr.length;
    var sum = 0;
    for (var i = 0; i < arrLen; i++){
      sum = arr[i];
    }
  • Do not cache

     
    var sum = 0;
    for (var i = 0; i < arr.length; i++){
      sum = arr[i];
    }