← 문제 목록
고급 JavaScript 100P

Private Class Fields

다음 코드에서 오류가 발생하는 이유는?
JAVASCRIPT
class BankAccount {
    #balance = 0;
    deposit(amount) { this.#balance += amount; }
    getBalance() { return this.#balance; }
}
const account = new BankAccount();
account.deposit(1000);
console.log(account.#balance);

답변

로그인 후 제출하기
0명 풀이 · 정답률 0%