"this" vs reference (v2)

Revision 2 of this benchmark created on


Setup

var a = {
      count: 0,
      incrThis: function () {
        for ( var i = 0; i < 10000; i++ ) {
            this.count++;
        }
      },
      incrA: function () {
        for ( var i = 0; i < 10000; i++ ) {
            a.count++;
        }
      },
      incrLocalA: function () {
        var a = this;
        for ( var i = 0; i < 10000; i++ ) {
            a.count ++;
        }
      }
    };

Test runner

Ready to run.

Testing in
TestOps/sec
this
a.incrThis();
ready
reference
a.incrA();
ready
local reference
a.incrLocalA();
ready

Revisions

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