Created
December 7, 2014 12:35
-
-
Save jdivock/47f4632f75a7e3f5807d to your computer and use it in GitHub Desktop.
inheritance example
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
// Code goes here | |
var Parent = function(foo1){ | |
this.foo1 = foo1 | |
} | |
Parent.prototype.derp = function(){ | |
console.log('derp derp'); | |
} | |
var par1 = new Parent('hi'); | |
console.log(par1); | |
var Child = function(foo1){ | |
Parent.call(this, foo1) | |
}; | |
Child.prototype = new Parent(); | |
var child1 = new Child('derpina'); | |
console.log('child', child1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment