Skip to content

Instantly share code, notes, and snippets.

@icholy
Last active August 29, 2015 14:09
Show Gist options
  • Save icholy/36dfeb04845f3649c6d9 to your computer and use it in GitHub Desktop.
Save icholy/36dfeb04845f3649c6d9 to your computer and use it in GitHub Desktop.
Go style javascript

Js style (one of many):

// constructor
var Foo = function () {};

// private
Foo.prototype._poo = function () {};

// public
Foo.prototype.bar = function () {};

Go style js:

var Foo = Object.create(Function);

// constructor
Foo.New = function () {
  return Object.create(Foo.prototype);
};

// private
Foo.prototype.poo = function () {};

// public
Foo.prototype.Bar = function () {};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment