Created
April 16, 2018 13:41
-
-
Save anurag-majumdar/4391c60ac37be94a908b514f150ede17 to your computer and use it in GitHub Desktop.
Comparison between ES6 and traditional approach to extending classes
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 style | |
class Gorilla extends Animal { | |
constructor(name, weight) { | |
super(name, weight); | |
} | |
//... | |
} | |
// Traditional style | |
function Gorilla(name, weight) { | |
Animal.call(this, name, weight); | |
} | |
Gorilla.prototype = Object.create(Animal.prototype); | |
Gorilla.prototype.constructor = Gorilla; | |
//... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment