Skip to content

Instantly share code, notes, and snippets.

@dengjonathan
Created November 16, 2016 03:57
Show Gist options
  • Save dengjonathan/2eb1cfaac24c1b3ba32e07098c2286fa to your computer and use it in GitHub Desktop.
Save dengjonathan/2eb1cfaac24c1b3ba32e07098c2286fa to your computer and use it in GitHub Desktop.
oop inheritance
//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