private or public proto helper

Benchmark created by Alex Wayne on


Setup

function Dog() {}
    Dog.prototype._helper = function() {};
    Dog.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
public underscored
var dog = new Dog();
dog.eat();
ready
truly private
var cat = new Cat();
cat.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