Let's consider a scenario where we have the following class:
export class PersonInformation {
constructor(
public firstName: string = "",
public lastName: string = "",
public middleName: string = "",
) { }
}
Now, we're looking to set the initial values for these variables specified in the constructor by passing a JSON object during the creation of the object.
For instance:
var personInfo = new Person({
"firstName" : "John",
"lastName" : "Doe",
"middleName" : ""
});