Created
January 8, 2012 23:23
-
-
Save haileys/1580084 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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