JavaScript Scope Chain (v7)

Revision 7 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() {
   return this.local;
  }
 };
})(window);

obj.test();
ready
Object reference
(function(window) {
 window.obj = {
  local: 0,
  test: function() {
   return window.obj.local;
  }
 };
})(window);

obj.test();
ready

Revisions

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