Created
November 13, 2011 12:46
-
-
Save johnhunter/1362075 to your computer and use it in GitHub Desktop.
Example JavaScript Pseudo-class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you like OOP Classes then this might be useful. A module encapsulates the class members and returns the constructor.