Object.mixin rather than Object.getOwnPropertyDescriptors
andrea.giammarchi at gmail.com
Tue Apr 22 10:58:11 PDT 2014
while I think that
looks semantically better than
I also think that Object.mixin could be used for similar cases but I am not
1. is able to mixin also not enumerable and Symbols
2. performs some unrequired magic such rebinding getters and setters
that should not happen or actually does not make sense to me
The reason such long method name has been proposed was for symmetry with
defineProperties and as meaningful plural version that should not exclude
Long story short, when mixin is needed, use mixin, otherwise when all
descriptors are needed, use getOwnPropertyDescriptors?
In few words I don't see how having both could hurt anyone
On Tue, Apr 22, 2014 at 10:27 AM, Claude Pache <claude.pache at gmail.com>wrote:
> There has been request to add `Object.getOwnPropertyDescriptors` (plural)
> to the standard. Reviewing use cases presented in thread  or in older
> thread , it seems to me that all of them boil down to copy all own
> properties of one object to another, e.g.,
> Object.create(proto, Object.getOwnPropertyDescriptors(source))
> // etc.
> However, this is exactly what `Object.mixin` (deferred from ES6) was
> designed for:
> Object.mixin(target, source)
> Object.mixin(Object.create(proto), source)
> // etc.
> Besides being shorter to write, `Object.mixin` has the advantages of (1)
> not creating an intermediate object; (2) taking care of some subtleties,
> like rebinding `super` for methods, getters and setters if needed.
> Therefore, I think that `Object.mixin` is a better function to have than
>  http://esdiscuss.org/topic/object-getownpropertydescriptors-o-plural
>  http://esdiscuss.org/topic/object-getownpropertydescriptor
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss