SOURCE

class handleGSetter {
    constructor() {
        this.array = ['apple', 'banana']
    }
    get firseFruit() {
        console.log('getter')
        return this.array[0]
    }
    set firseFruit(value) {
        console.log('setter')
        this.array[0] = value
    }
}

const fruit = new handleGSetter()

// const first = fruit.array[0];
console.log(fruit.firseFruit)

fruit.firseFruit = 'Watermelon';
console.log(fruit.firseFruit)
console 命令行工具 X clear

                    
>
console