Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@johnhunter
Created November 13, 2011 12:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save johnhunter/1362075 to your computer and use it in GitHub Desktop.
Save johnhunter/1362075 to your computer and use it in GitHub Desktop.
Example JavaScript Pseudo-class
// Example Pseudo-class
var Animal = (function() {
function Animal(name) {
this.name = name;
}
Animal.prototype.getName = function () {
return this.name;
};
return Animal;
}());
var dog = new Animal('Fido');
console.log(dog.getName());
@johnhunter
Copy link
Author

If you like OOP Classes then this might be useful. A module encapsulates the class members and returns the constructor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment