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)