4

Behind the scene, is the ES6 class based inheritance is exactly same as es5 prototypal inheritance or not? If not, what is the difference? Is chrome does the same as of ES6 tranpilers, i mean internally compile the es6 classes to function constructor?

atul bajpai
  • 155
  • 1
  • 1
  • 7

2 Answers2

1

Under the hood it's the same implementation, "class" in Javascript is just a syntactic sugar.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes

JavaScript classes, introduced in ECMAScript 2015, are primarily syntactical sugar over JavaScript's existing prototype-based inheritance.

Mike Ezzati
  • 2,968
  • 1
  • 23
  • 34
0

Browsers will treat it the same if it's supports ES6 class, otherwise your code written in class based inheritance will cause an error on the browser. So one of the difference you could consider is the browser support.