forbes at lindesay.co.uk (2014-07-14T14:19:55.757Z)
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?
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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140508/c75c8112/attachment.html>