I am exploring the use of interfaces in my models and want to establish a default value for them.
export interface IPerson {
id: string;
name: string;
}
class Person implements IPerson {
id = '';
name = 'John';
}
export class Family {
constructor(public address: string,
public members: Person[] = [new Person()]) {
}
My goal is to create a family where, if a person does not have a name defined, it defaults to John.
In some cases, a person gets created with a name set to null.
Any suggestions on how I can achieve this?