Skip to content

Instantly share code, notes, and snippets.

@keyle
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save keyle/9755741 to your computer and use it in GitHub Desktop.

Select an option

Save keyle/9755741 to your computer and use it in GitHub Desktop.
object oriented javascript a la typescript
var App = (function () {
function App() {
console.log("App constructor");
}
App.prototype.init = function () { // poluting the prototype => instance method
console.log("app.init() is instance init \n" + this);
};
App.init = function () { // static method
console.log("App.init() is static init \n" + this);
};
return App;
})();
var app;
window.onload = function () {
console.log("--- static init: ---");
App.init();
console.log("\n--- instance init: ---");
app = new App();
app.init();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment