DEV Community


Discussion on: 10 JavaScript concepts you need to know for interviews

mortoray profile image
edA‑qa mort‑ora‑y

With the advent of the class keyword in ES6, is it still necessary to understand prototype and friends?

martinhaeusler profile image
Martin Häusler

Unfortunately yes, even with the nicer syntax it's still plain old prototype chain. They missed the historical opportunity to clean up this mess.

arnavaggarwal profile image
arnav-aggarwal Author

Absolutely. The class keyword uses prototypes in its implementation. It's just "syntactic sugar", or a simpler way of using prototypes, but we're still using prototypes nonetheless. It's key to the core of OOP in JS.

mladenstojanovic profile image
Mladen Stojanovic

I think it is, because, in the background, class still uses prototype chain etc. You might understand some things better (or debug faster) if you understand how it really works.

codypatnaude profile image

The class keyword is just different syntax for creating objects. Once the object is created it still uses the same prototypal inheritance objects always have.

Using the 'class' keyword without understanding prototypal inheritance is like building a house with no understanding of carpentry. Eventually something's going to break, and you won't know how to fix it.

Forem Open with the Forem app