mirror of
https://github.com/denoland/deno.git
synced 2024-12-30 02:59:11 -05:00
21 lines
388 B
TypeScript
21 lines
388 B
TypeScript
|
export class Person {
|
||
|
#name: string;
|
||
|
constructor(name: string) {
|
||
|
this.#name = name;
|
||
|
}
|
||
|
|
||
|
equals(other: unknown) {
|
||
|
return other &&
|
||
|
typeof other === "object" &&
|
||
|
#name in other &&
|
||
|
this.#name === other.#name;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const a = new Person("alice");
|
||
|
const b = new Person("bob");
|
||
|
const c = new Person("alice");
|
||
|
|
||
|
console.log(a.equals(b));
|
||
|
console.log(a.equals(c));
|