iw<=>say ... "is way"
On Thu, May 8, 2014 at 2:38 PM, Andrea Giammarchi < [email protected]> wrote: > that does not save you from errors when `Object.prototype.get = > function(){}` since `writable` and `get/set` cannot coexist in a descriptor > ... a safe approach is to create `var descriptor = Object.create(null);` > and then set its `value` later on before assignment. > > I remember early discussion with Allen and Brendan about this, the > solution was a hybrid [[HasNonObjectProperty]] check so that everything > inherited except `Object.prototype` was considered ... although: > > 1. we have two kind of descriptors, accessors and value descriptors. I > don't know who would create classes in order to inherit just a couple of > propeties ... like `new WritableButNotConfigurable(value)` ? Has anyone > ever seen a piece of code like that? > 2. accordingly to point one, descriptors should rather change into > `null` objects ASAP and stop this descriptor minefield I am pretty sure > nobody expect or desire to work like that > > Changing that part of the specs iw say easier than defining a new > [[HasNonObjectProperty]] pattern, IMO > > My 2 cents > > > On Thu, May 8, 2014 at 1:25 PM, John-David Dalton < > [email protected]> wrote: > >> ES6 additions like Object.assign use [[OwnPropertyKeys]] for getting the >> keys of `source` objects. This helps avoid the method gotchas faced by >> developers previously with things like `Object.prototype.writable = true` >> and `Object.defineProperty(o, 'foo', { value: 'bar' })`. >> >> See >> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty#Description(bottom >> of section) >> >> "Bear in mind that these options are not necessarily own properties so, >> if inherited, will be considered too. In order to ensure these defaults are >> preserved you might freeze the Object.prototype upfront, specify all >> options explicitly, or point to null as __proto__ property." >> >> It's the reason I pre-populate my descriptor attributes with false even >> though false is the default. See >> https://github.com/lodash/lodash/blob/2.4.1/dist/lodash.js#L112-L117 >> >> With methods like Object.assign using [[OwnPropertyKeys]] does it make >> sense to make things like ToPropertyDescriptor use [[HasOwnProperty]] too. >> I think it would be a win for consistency and dev use. >> >> Thoughts? >> >> - JDD >> >> _______________________________________________ >> es-discuss mailing list >> [email protected] >> https://mail.mozilla.org/listinfo/es-discuss >> >> >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

