Last active
August 29, 2015 14:25
-
-
Save yesvods/20ac2d0940cbc254f4fa to your computer and use it in GitHub Desktop.
ES6 Class inherit
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
//ES6 Class inherit example | |
class Person{ | |
sayName(){ | |
console.log(this.name); | |
} | |
} | |
class Classmate extends Person { | |
constructor(name){ | |
super() | |
this.name = name; | |
} | |
} | |
//create an instance | |
var xiaohong = new Classmate('xiaohong') | |
xiaohong.sayName(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment