Created
August 19, 2013 03:54
-
-
Save lylijincheng/6265638 to your computer and use it in GitHub Desktop.
ES5 oo sample.
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 | |
Class Vehicle { | |
constructor(color) { | |
this.color = color; | |
this.speed = 0; | |
} | |
drive() { | |
this.speed = 40; | |
} | |
} | |
// ES6 inherit | |
class Car extends Vehicle { | |
constructor(brand, color) { | |
super(color); | |
this.brand = brand; | |
this.wheels = 4; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment