I am trying to make the method getColor()
non-configurable, but when I tried to refer to the current instance property of the Fruit "class" using this.color
it did't work. Seems like this
doesn't refer to the Fruit
instance. How can I refer to the instance?
The function body defined for the property isn't a mutator, here its just an example
Object.defineProperty(Fruit.prototype, 'getColor', {
writable: false,
configurable: false,
enumerable: false,
value: function(){
return this.color; // this refers to Object here
}
});