function Fruit() { let _skillLevel = 0; Object.defineProperty(this, 'skillLevel', { get: () => { console.log('get') return _skillLevel; }, set: value => { console.log('set', value) _skillLevel = value } }) } const fruit = new Fruit(); console.log(fruit.skillLevel); fruit.skillLevel = 2; console.log(fruit.skillLevel);