I am looking to instantiate the following class:
class Person {
firstName;
lastName;
birthday;
constructor(props: Person) {
{firstName, lastName, birthday} = props
}
}
var me = new Person({firstName: "donald",
lastName: "trump",
middleName: "john"})
My goal is for the constructor to only assign the class properties to "this," resulting in me
being
{firstName: "donald", lastName: "trump", birthday: undefined}
One approach I am considering is:
class Person {
firstName;
lastName;
birthday;
constructor(props: Person) {
this.{firstName, lastName, birthday} = props
}
}
var me = new Person({firstName: "donald", lastName: "trump", middleName: "john"})
or a similar solution.