Object.assign( target, source )
Rough spec expectations:
- Only enumerable own properties of source
- Invoke [[Get]] on property list derived from source, for each property in list [[Put]] on target
- private names are not copied
- unique names are copied
- super mechanism (rebind super)… AWB To determine needs
- Returns modified "target"
I agree that
Object.assign
should be variadic. It makes not that much sense being non-variadic and forcing the users to jump through hoops to compose basic use cases when it could easily maintain the composition properties it already has and cover those use cases by just allowing multiple sources.Why? It's easier to follow for static arguments (and doesn't mess with ASI!):
It can cover non-static arguments through both the familiar .apply and the
Array::reduce
:On another note, I do find
assign
to have strong associations with replacing values and working with a single key/value association. I don't thinkdefine
describes the operation being carried out that well either, but right now I can't think of any better names =/