Rick Waldron wrote:
On Tue, Dec 11, 2012 at 12:28 PM, Allen Wirfs-Brock
<[email protected] <mailto:[email protected]>> wrote:
It also made me think that perhaps Object.mixin might be a more
intuitive name for such a function.
This name is certainly more real-word-friendly.
The example code that follows "A pure ECMAScript 5 version of mixin()
would be:" is basically what I imagined Object.define would be, but with
a slight modification in that Object.assign returns the target object,
so should Object.mixin:
Yes.
Object.mixin = function(receiver, supplier) {
return Object.keys(supplier).reduce(function(receiver, property) {
return Object.defineProperty(
receiver, property, Object.getOwnPropertyDescriptor(supplier,
property)
);
}, receiver);
};
I know this may look like a nitpick, but, why such clever code? I had
the problem reading it (I just skipped it); I see no "reducing" process
here. Maybe I am just not functional enough. I wouldn't use inject:into:
when doing this in smalltalk, but do:.
What's wrong with forEach followed by return receiver?
Rick
Herby
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss