Allen Wirfs-Brock (2015-04-21T00:17:43.000Z)
On Apr 20, 2015, at 12:42 PM, Caitlin Potter wrote:

> Oh — he’s right, ValidateAndApplyPropertyDescriptor won’t throw in the example case, because the old descriptor is configurable. That’s kind of weird.

It is kind of weird, but that was what TC39 decided on back when ES5 was being developed.  The logic was that if a property is configurable then it is possible to change all of its attributes  by performing a [[DefineOwnProperty]] with a complete property description.   Because of that possibility, all changes made via a partial property descriptor are also accepted.  In other words:

var o = Object.create(null, {x:{value: 0, writable: false, enumerable: true, configurable:true}});
Object.defineProperty(o,' x', {value:2});
console.log(o.x); //2

The define property above is allowed because it could have been replaced with the sequence :
Object.defineProperty(o,'x', {writable: true});
Object.defineProperty(o,'x', {value: 2, writable: false});

or even by:
delete o.x;
Object.defineProperty(o,'x', {value: 2, writable: false, enumerable: true, configurable: true};)

hence, we might as well accept the single line version.

In retrospect, perhaps not such a good idea. 

Allen
d at domenic.me (2015-05-01T13:01:18.552Z)
On Apr 20, 2015, at 12:42 PM, Caitlin Potter wrote:

> Oh — he’s right, ValidateAndApplyPropertyDescriptor won’t throw in the example case, because the old descriptor is configurable. That’s kind of weird.

It is kind of weird, but that was what TC39 decided on back when ES5 was being developed.  The logic was that if a property is configurable then it is possible to change all of its attributes  by performing a [[DefineOwnProperty]] with a complete property description.   Because of that possibility, all changes made via a partial property descriptor are also accepted.  In other words:

```js
var o = Object.create(null, {x:{value: 0, writable: false, enumerable: true, configurable:true}});
Object.defineProperty(o,' x', {value:2});
console.log(o.x); //2
```

The define property above is allowed because it could have been replaced with the sequence :

```js
Object.defineProperty(o,'x', {writable: true});
Object.defineProperty(o,'x', {value: 2, writable: false});
```

or even by:

```js
delete o.x;
Object.defineProperty(o,'x', {value: 2, writable: false, enumerable: true, configurable: true};)
```

hence, we might as well accept the single line version.

In retrospect, perhaps not such a good idea.