Created
August 23, 2019 18:38
-
-
Save jeremyckahn/768505ac1c4a0982221fb0df5c965136 to your computer and use it in GitHub Desktop.
Refresher on prototypal inheritance
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
function Parent () { console.log('parent') } | |
Parent.prototype.parentMethod = function () { console.log('this is a method on the parent object') } | |
function Child () { console.log('child') } | |
Child.prototype = new Parent() | |
var child = new Child() | |
child.parentMethod() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment