Let's talk about a class called Email
class Email {
private _from: string;
private _to: Array<string>;
private _subject: string;
}
When an email object is created, it will look something like this:
{
_from:'',
_to:'',
_subject:''
}
I find it strange that I can't directly use this object to send to a function. It seems like I'll need to transform the object so that it doesn't have underscores. Do I really have to do this or is there a way to use the underscore convention as is?
EDIT: Removing the _
If we name the private variables without underscore, how should we name the getters and setters? A VSCode plugin called Typescript toolbox suggests using something like this:
public get $subject(): string {
return this.subject;
}
Is using $
as a prefix for getters a good convention?