Object.getOwnPropertyDescriptors(O) ? // plural
Andrea Giammarchi
andrea.giammarchi at gmail.com
Tue Mar 4 16:38:40 PST 2014
You are right, I've realized it after posting ... `Object.assign(target,
source)` via `Get` and `Put` is basically the equivalent of a classic
`for/in` with `hasOwnProperty` check ... well, once again, in ES6
`Object.getOwnPropertyDescriptors(O)` seems to be a solution for other
cases too (shallow copy of properties, shallow clone, not just for/in) plus
yes, `Object.mixin(target, source)` might be simplified as well via this
proposal, that's a good point ... so 3 problems solved at once! :-)
On Tue, Mar 4, 2014 at 4:02 PM, Claude Pache <claude.pache at gmail.com> wrote:
>
>
> Le 5 mars 2014 à 00:18, Andrea Giammarchi <andrea.giammarchi at gmail.com> a
> écrit :
>
>
> Also please note that this proposal simplifies [Object.assign(target,
> source)](
> https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign)
> too since latter one is basically:
>
> ```javascript
> Object.defineProperties(
> target,
> Object.getOwnPropertyDescriptors(source)
> );
> ```
>
>
> No. `Object.assign` (1) uses the semantics of the assignment operator `=`
> (for example, it makes a difference in case of setters), and (2) copies
> only enumerable properties. Did you think about `Object.mixin`?
>
> --Claude
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140304/e4f2adc1/attachment.html>
More information about the es-discuss
mailing list