Module Pattern vs Anonymous Constructor

Benchmark created by cdsanchez on


Test runner

Ready to run.

Testing in
TestOps/sec
Module Pattern
var module = (function () {
   var a = 1337;
   return {
      getA: function () {
         return a;
      }
   }
})();
ready
Anonymous Constructor
var module = new function () {
   var a = 1337;
   this.getA = function () {
      return a;
   };
}
ready

Revisions

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