Skip to content

Instantly share code, notes, and snippets.

@anurag-majumdar
Created April 16, 2018 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anurag-majumdar/4391c60ac37be94a908b514f150ede17 to your computer and use it in GitHub Desktop.
Save anurag-majumdar/4391c60ac37be94a908b514f150ede17 to your computer and use it in GitHub Desktop.
Comparison between ES6 and traditional approach to extending classes
// 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