Object.define ==> Object.mixin??

Herby Vojčík herby at mailbox.sk
Wed Dec 12 07:48:04 PST 2012


Brandon Benvie wrote:
> Works well as an arrow function due to not needing to turn it into a
> block body, although forEach and a comma would work too.
>
> Object.mixin = (target, source) =>
>    Object.keys(source).reduce((target, key) =>
>      Object.defineProperty(target, key,
> Object.getOwnPropertyDescriptor(source, key))
>     ), target);

Ah. Yeah. Guess I am really not very much functional. Probably the 
unneeded ever-copied same result-to-argument premature optimization was 
ringing, too.


More information about the es-discuss mailing list