ES6 class declaration

JavaScript

ES6 introduced a new syntax for declaring a class as shown in this example👆

This Person class behaves like the Person type in the previous example.

However, instead of using a constructor/prototype pattern, it uses the class keyword.

In the Person class, the constructor() is where you can initialize the properties of an instance.

JavaScript automatically calls the constructor() method when you instantiate an object of the class.

Leave a Reply

Your email address will not be published. Required fields are marked *