In Javascript, we can add a property to an object with:
obj.property = value;
However, sometimes we would like to have fine-grained control over properties.
With Object.defineProperty()
, we can decide:
Descriptor | Purpose | Default |
---|---|---|
value | Property value | undefined |
writable | Whether the property can be assigned | false |
get | Getter of the … |