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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more