There is a unique class named tax
.
export class tax {
private _id: string;
private _name: string;
private _percentage: number;
constructor(id: string = "", taxName: string = "", percentage: number = 0) {
this._id = id;
this._name = taxName;
this._percentage = percentage;
}
public get id(): string {
return this._id;
}
public set id(v: string) {
this._id = v;
}
public get name(): string {
return this._name;
}
public set name(v: string) {
this._name = v;
}
public get percentage(): number {
return this._percentage;
}
public set percentage(v: number) {
this._percentage = v;
}
toString(){
return this.id;
}
}
If two objects of this class are created:
a1: tax = new tax("id","name",4);
a2: tax = new tax("id","name",4);
console.log(a1 === a2); //false
console.log(a1 == a2); //false
In order for `a1 === a2` to return true, what modifications should be made in the class? Which method needs to be overridden in the tax class?