private or public proto helper (v2)

Revision 2 of this benchmark created by ian drake on


Setup

function Dog() {}
    Dog.prototype._helper = function() {};
    Dog.prototype.eat = function() {
      this._helper();
    }
    
    function Dog2() {}
    //Dog2.prototype._private = {};
    Dog2.prototype._helper = function() {};
    Dog2.prototype.eat = function() {
      this._helper();
    }
    
    
    var Cat = (function() {
      var Cat = function() {};
      var helper = function() {};
      Cat.prototype.eat = function() {
        helper.call(this);
      }
      return Cat;
    })();

Test runner

Ready to run.

Testing in
TestOps/sec
Test
var dog2 = new Dog2();
dog2.eat();
ready
truly private
var cat = new Cat();
cat.eat();
ready
Public underscore
var dog = new Dog();
dog.eat();
ready

Revisions

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

  • Revision 1: published by Alex Wayne on
  • Revision 2: published by ian drake on