The ES6 JS classes serve as a starting point for the creation of objects. They encapsulate data with code that allows them to work with it.
JavaScript Classes were implemented in ECMAScript 2015, also known as ES6.
JavaScript Classes are templates for JavaScript Objects and a JavaScript class is not an object.
Table of Contents
Syntax of a Classe in JavaScript
class declaration
A class declaration is one way to define a class. You use the class keyword with the class name to declare a class.
Use the keyword ” class ” to create a class.

class expression
Another way to define a class is to use a class expression. There are two types of class expressions: named and unnamed.
The following example explains class expression.

The Objects, how to use the JS classes?
You can use the class to create objects. The new keyword is used to create objects of classes. The syntax of creating objects is as follows.

You can now use this object to retrieve data and methods from the class. for example, we will create a class and retrieve its data.

Consider constructor() as part of ES6 JS class syntax
So far we have seen the basic syntax of class. now we will explain the Constructor and its importance in any class.
What is a constructor() method in Javascript? t is a special method for creating and initializing an “object” generated with a class.
When a class is created, the constructor method is called automatically, and it must have the exact name “constructor“
For example
