TypeScript

public, private & protected (TS)

Në shqip: Modifikuesit e aksesit në TS

ShpjegimiSQ

TypeScript ka public (kudo), private (vetëm brenda klasës) dhe protected (klasa dhe bijat). Kujdes: këto kontrollohen vetëm gjatë kompajlimit — për privatësi të vërtetë përdor #fusha.

EnglishEN

TypeScript has public (anywhere), private (only inside the class) and protected (the class and its children). Careful: these are checked only at compile time — for real privacy use #field.

Si ta mendosh

Si dyert me tabela „Vetëm për stafin“ — të respektueshme, por jo me çelës.

Lexoje në anglisht

Like doors marked “Staff only” — respected, but not locked.

Shembull koditypescript

class Llogari {
  protected bilanci = 0;
  private pin = "1234";
  public shfaq() { return this.bilanci; }
}

Terma të lidhur