ES6 class declaration

JavaScript

ES6 class declaration

  • 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.

JavaScript class

javascript class
  • A JavaScript class is a blueprint for creating objects.
  • A class encapsulates data and functions that manipulate data.

Leave a Reply

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