Module Pattern vs Anonymous Constructor (v3)

Revision 3 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Hanna
Container = (function() {
    var _that   = this;         // Private
    var _secret = null;         // Private
    
    // Call to private function
    _init(param);
   
    // Private function
    function _init(param) {
        _secret = param;
    }

   return {
      // Public function 
    this.getInstance = function() {
        return _that;
    }
 
    // Private function
    function _init(param) {
        _secret = param;
    }
     
   }
})();
ready
Philip
function Container(param) {        
    // Declare memeber variables
    this.value  = 5;            // Public
    var _that   = this;         // Private
    var _secret = null;         // Private
 
    // Call to private function
    _init(param);
 
    // Public function
    this.getSecret = function() {
        return _secret;
    }
 
    // Public function 
    this.getInstance = function() {
        return _that;
    }
 
    // Private function
    function _init(param) {
        _secret = param;
    }
}
ready

Revisions

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