Created
July 18, 2016 17:06
-
-
Save ibolmo/4cd51a9dc88f6cae22678db164087d91 to your computer and use it in GitHub Desktop.
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
var Animal = function(name){ | |
this.name = name; | |
}; | |
Animal.prototype.speak = function(){ | |
console.log(this.name); | |
}; | |
var Dog = function(name){ | |
Animal.call(this, name); | |
}; | |
Dog.prototype = Object.create(Animal.prototype); | |
Dog.prototype.speak = function(){ | |
console.log('woof'); | |
}; | |
var pup = new Dog('fido'); | |
pup.speak(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment