De-sugar an ES6 Class and the Extends Keyword

InstructorTyler Clark

Share this video with your friends

Send Tweet

Sure you've seen and heard of the ES6 class keyword. You might of also used the extends keyword before in order to subclass your class as well. However, do you actually understand what is happening behind the scenes? Could you de-sugar these keywords into basic programming functions? In this lesson we work with two classes that use the extends keyword and recreate them with functions and built in methods. We also talk about some of the differences between a function and a class.

mirakl
~ 5 years ago

"two layers deep in our proto chain is the global Object.prototype object, even though we connect the two functions up here with the setPrototypeOf."

As you said, we might be surprised by this :) why is this happening ?

Tyler Clarkinstructor
~ 5 years ago

This is just the spec of the new keyword against functions. Classes have additional logic built in that tells the new keyword functionality to continue through the chain to connect it all... but functions simply do not.

mirakl
~ 5 years ago

Thanks ! Very high quality course by the way, congrats :)