Do You Really Know Object.defineProperty ?
I am talking about enumerable , configurable , and writable properties of a generic property descriptor. enumerable most likely the only one we all expect: if false, a classic for/in loop will not expose the property, otherwise it will. enumerable is false by default. writable just a bit more tricky than we think. Nowadays, if a property is defined as non writable, no error will occur the moment we'll try to change this property: var o = {}; Object.defineProperty(o, "test", { writable: false, value: 123 }); o.test; // 123 o.test = 456; // no error at all o.test; // 123 So the property is not writable but nothing happens unless we try to redefine that property. Object.defineProperty(o, "test", { writable: false, value: 456 }); // throws // Attempting to change value of a readonly property. Got it ? Every time we would like to set a property of an unknown object, or one shared in an environment we don't trust, either we use a try/catch plus double ...