Created
July 20, 2016 09:35
-
-
Save vasergen/f48464173ee37365b3d493b24af76803 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 inheritance | |
function Animal(name) { | |
this.name = name | |
this.say = function() { | |
console.log(`I am ${this.name}`) | |
} | |
} | |
function Rabbit(name) { | |
Animal.call(this, name) | |
this.skip = function() { | |
console.log(this.name + ': I skip') | |
} | |
} | |
let r1 = new Rabbit('r1') | |
r1.say() | |
r1.skip() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment