I have code that defines a getter (but no prototype, if any) on the prototype. The return value is true in 99.99% of cases; however, the goal is to set the property to be evaluated to a different value for a particular object.
foo = {} Object.defineProperty(foo, "bar", { // only returns odd die sides get: function () { return (Math.random() * 6) | 1; } }); x = Object.create(foo); x.bar // => eg. 5 x.bar = 4 // by fair dice roll x.bar // nope => eg. 3
How to override a property for x, an existing object, so that it can be assigned (for example, has a property property by default)?
Addition. Although a new property (value or get / set) can be defined in x, I am looking for if there is a way to stop the behavior of the property in [prototype] and include "bar" back in normal / ad-hoc for a specific instance.
source share