JavaScript Scope Chain

Benchmark created by Kyle Florence 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

Revisions

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