DEV Community

Cover image for Javascript classes explanation in a simple way
Lukasz
Lukasz

Posted on

Javascript classes explanation in a simple way

Classes were added to Javascript in ECMAScript 2015 (ES6). They are not typical classes like in other object-oriented languages ie. Java.

Class in Javascript is syntactic sugar

The class in JS is helpful, facilitating syntactic sugar. It is nothing more than a regular function that receives an argument, and then this argument is assigned to the object THIS.
In the case when a class has a method, this method is assigned to the prototype of this object.

Class equivalent in Javascript

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay