Object.mixin( source, target ) | arguments changed

Rick Waldron waldron.rick at gmail.com
Thu Jun 13 10:04:43 PDT 2013

On Thu, Jun 13, 2013 at 11:38 AM, Tobias Buschor
<tobias.buschor at gmail.com>wrote:

> I propose to change the arguments.
> The second argument "target" is optional and default to
> "Object.create(null)"

This can already be achieved with Object.mixin(Object.create(null), source)
or if you've imported the dict module (or dict from whatever module it
lives in) Object.mixin(dict(), source)

> The return-value is the modified target

This is already true.

> Advantages:
>   - Without the second argument, we can copy the source

This can already be achieved with Object.mixin({}, source).

>  - It is more natural to say "mixin the source into the target" =>
> misin.(source, target)

Subjectively, maybe? None of the existing cow-highways look like this.

> Disadvantages
>  - Its not suitable to extend the function to accept multiple sources in
> the future

It also means that Object.assign's arguments would have to be flipped.

Based on this and the example shown above, I think it's fair to say that
reversing the arguments isn't in the ES6's best interest.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130613/5962f68b/attachment-0001.html>

More information about the es-discuss mailing list