FrontEnd.ro logo
Proprietăți Private

class CreditCard {
  // private variable
  #number;

  constructor() {
    this.#number = '...';
  }

  // private function
  #getNumber() {
    return this.#number;
  }

  getInfo() {
    const lastFour = this.#getNumber().slice(-4);
    return `Last four numbers: ${lastFour}`;
  }
}