Prateek's Blog

Subscribe
Archives
January 3, 2022

How JavaScript Classes work under the hood

Hey there!

First of all, Happy New Year! 2021 has been a wild year for all of us, maybe it wasn’t as bad as 2020, but it was still a rollercoaster of a year with plenty of ups and downs and wtf moments. So I wanted to start this year by publishing a post that I have been procrastinating for quite some time.

If you have been using JavaScript for a while now, chances are you have come across classes in JavaScript. The class keyword was officially introduced in JavaScript with ES6 in 2015. Still, the classes created with the class keyword are mostly just syntactic sugar over the already existing pre-ES6 syntax for creating objects with custom prototypes.

So in this post, I try to exemplify what prototypes are in JavaScript and how they are a core part of the language, how you can create classes without using the class keyword with constructor functions, what prototype chaining is and how it helps with inheritance, and lastly, how do all these concepts apply to the JavaScript classes we know.

Give it a read here! - How JavaScript Classes work under the hood

Here’s to a great 2022! ✨

- Prateek

Don't miss what's next. Subscribe to Prateek's Blog:
Powered by Buttondown, the easiest way to start and grow your newsletter.