summaryrefslogtreecommitdiff
path: root/tests/specs/run/private_field_presence/private_field_presence.ts
blob: 7ce2840d8e3edd387de1a42e93886244df895ae9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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));