I was trying out this really simple example from the awesome \"Professional JavaScript for Web Developers\" book by Nicholas Zakas but I can\'t figure what I am doing wrong
When you use Object.defineProperties, by default writable is set to false, so _year and edition are actually read only properties.
Explicitly set them to writable: true:
_year: {
value: 2004,
writable: true
},
edition: {
value: 1,
writable: true
},
Check out MDN for this method.
writable
trueif and only if the value associated with the property may be changed with an assignment operator.
Defaults tofalse.