JavaScript Objects Classes
JS
What is a class?
A class in JavaScript is a blueprint for creating objects. It lets you create multiple similar objects (instances) without repeating the code.
Classes were introduced in ES6 (2015). They make working with object-oriented patterns easier and more readable.
Defining a class
Use the class keyword:
constructor()
is a special method called automatically when you create a new object.this
refers to the new object being created.greet
is a method that can be called on any instance.