![]() |
VOOZH | about |
JavaScript class is a type of function declared with a class keyword, that is used to implement an object-oriented paradigm. Constructors are used to initialize the attributes of a class.
There are 2 ways to create a class in JavaScript.
The class expression is another way of creating classes in JavaScript and they can be named or unnamed. If named, the class name is used internally, but not outside of the class.
Syntax
const variable_name = new Class_name {
// class body
}
const variable_name = class{
//class body
}
Example 1: Named class expression
Example 2: Unnamed class expression.