getter

Javascript

클래스) getter, setter

class Player { numLives = 10 #score = 0 constructor(first, last) { this.#onNewbee() this.first = first this.last = last } get fullName() { return `whose name is ${this.first} of house ${this.last}` } set fullName(newName) { const [first, last] = newName.split(" ") this.first = first this.last = last console.log('FullName has changed') } set firstName(newFirst) { this.first = newFirst console.log..

2DC
'getter' 태그의 글 목록