Nested declaration vs Protopical inheritance (v2)

Revision 2 of this benchmark created by Quetzacotl on


Setup

var Nested = function(){
       this.x = function(x){
          return x+1;
       };
       this.y = function(y){
         return y-1;
       };
    };
    
    var Prototypical = function(){
    
    }
    
    Prototypical.prototype.x = function(x){
          return x+1;
       }
    Prototypical.prototype.y = function(y){
          return y+1;
       }
    
    var CrockfordInheritancePrototype = {
        x: function(x) {
            return x+1;
        },
        y: function(y) {
            return y+1;
        }
    };
    
    var CrockfordInheritance = function() {
        return Object.create(CrockfordInheritancePrototype);
    };

Test runner

Ready to run.

Testing in
TestOps/sec
Nested
new Nested();
ready
Prototypical
new Prototypical();
ready
Crockford
CrockfordInheritance();
ready

Revisions

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

  • Revision 2: published by Quetzacotl on