for loop cached array length vs for loop not cached array length

Edit on GitHub

Setup

Tests

  • for loop cached array length

    var a = {
      b: {
        c: {
          d: [21,321,65,876,435]
        }
      }
    };
    
    var length = a.b.c.d.length;
    for(var i = 0; i < length; i++) {
      console.log(i);
    }
  • for loop not cached array length

    var a = {
      b: {
        c: {
          d: [21,321,65,876,435]
        }
      }
    };
    
    for(var i = 0; i < a.b.c.d.length; i++) {
      console.log(i);
    }