Constructor functions

A class's constructor is a special function that has the same name as the class. The constructor is called automatically when you use the new operator to create a new instance of the specified class. For example, in the Person class example, you created two instances of the Person class, as shown below.

var person_1 = new Person("Nate", 32);
var person_2 = new Person("Jane", 28);

The constructor function often has parameters that are used to initialize properties of the each new instance of the class.

A class definition can contain only one constructor function.