In this lesson, we will look at another way of creating an object class and learn about constructors.
We can pass arguments to a class the same way we can pass arguments to functions. They are known as constructor parameters as they are assigned a value when the object is constructed using a class.
Let’s look at the syntax below:
As you can see, where we initially only had class classIdentifier, we now also have a parameter list. The rest of the code for creating a class is exactly the same.
Let’s now redefine our Person class using constructor parameters.