指定 Person.name 只能在类内访问,但 Person.getName() 方法可以在任何地方访问
class Person { @(7) name: string; public constructor(name: string) { this.name = name; } @(6) getName(): string { return this.name; } }
class Person { private name: string; public constructor(name: string) { this.name = name; } public getName(): string { return this.name; } }