Complete worked example
typescript
class Counter {
#count = 0;
increment(): void { this.#count++; }
value(): number { return this.#count; }
}
const counter = new Counter();
counter.increment();- Reasoning
- Only public operations expose and change the private count.