In-function vs prototype definition

Benchmark created on


Setup

InFunction = function() {
      this.name = "test";
      this.foo = function() {
        return this.name;
      };
    }
    
    Prototype = function() {
      this.name = "test";
    };
    Prototype.prototype.foo = function() {
      return this.name
    };

Test runner

Ready to run.

Testing in
TestOps/sec
In-function
var bar = new InFunction();
bar.foo();
ready
Prototype
var bar = new Prototype();
bar.foo();
ready

Revisions

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