Skip to content

Instantly share code, notes, and snippets.

@haileys
Created January 8, 2012 23:23
Show Gist options
  • Save haileys/1580084 to your computer and use it in GitHub Desktop.
Save haileys/1580084 to your computer and use it in GitHub Desktop.
function Animal(name) {
var self = {};
self.speak = function() {
console.log("zzz...");
};
self.getName = function() {
return name;
};
return self;
}
function Dog(name) {
var self = Animal(name);
self.speak = function() {
console.log("'Woof!' says " + self.getName());
};
return self;
}
var greyBlob = Animal("blob");
greyBlob.speak();
var rover = Dog("rover");
rover.speak();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment