how should I write my constructor if I am calling it using the following code
const person = new Person({
name,
gender
})
where both name and genders are string
Update:
This is what I have got in typescript:
interface Details {
name: string;
gender: string;
}
class Person {
name: string;
gender: string;
constructor({ name, gender }: Details) {
this.name = name;
this.gender = gender;
}
}
const person = new Person({
name: "John",
gender: "male",
});
console.log(person);