Created
November 16, 2016 03:57
-
-
Save dengjonathan/2eb1cfaac24c1b3ba32e07098c2286fa to your computer and use it in GitHub Desktop.
oop 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
//OOP | |
class Parent { | |
constructor(name, job) { | |
this.name = name; | |
this.job = job; | |
} | |
} | |
const solo = new Parent('Han', 'smuggler'); // {name: 'Han', job: 'smuggler'} | |
class Child extends Parent { | |
constructor(name, job, hero) { | |
super(name, job); | |
this.hero = hero; | |
} | |
} | |
const ren = new Child('Kylo', 'Knight of Ren', 'Darth Vader') | |
// {name: 'Kylo', job: 'Knight of Ren', hero: 'Darth Vader'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment