JavaScript Scope Chain (v5)

Revision 5 of this benchmark created by Erik 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
Using 'this' and return object
window.obj = (function() {
 return {
  local: 0,
  test: function() {
   return this.local;
  }
 };
})();
obj.test();
ready

Revisions

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