JavaScript Scope Chain (v3)

Revision 3 of this benchmark created on


Description

Test case for which access method is fastest in relation to the JavaScript scope chain.

Test runner

Ready to run.

Testing in
TestOps/sec
Private variables
(function(window) {
 var local = 0;

 window.obj = {
  test: function() {
   return ++local;
  }
 };
})(window);

obj.test();
ready
Using 'this'
(function(window) {
 window.obj = {
  local: 0,
  test: function() {
var $this = this;
   return ++$this.local;
  }
 };
})(window);

obj.test();
ready

Revisions

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