Batch assignment functions

Brendan Eich brendan at mozilla.org
Wed Aug 15 14:30:23 PDT 2012


Rick Waldron wrote:
> As a result, I re-drafted Object.assign based on the real-world use 
> cases, but specifically does not attempt nested object property 
> assignment recursion. At this point I still believe that the deep 
> nested assignement case is strong enough to consider, but I'm not sure 
> how to approach it. It might warrant its own implicit "merge object 
> properties whenever possible"... Object.merge?

Object.merge, maybe -- but definitely do not want this muddled into 
assign/define or put/define or whatever those shallow-only names should be.

> In summary, based on findings so far, I'd like to propose the following:
>
> In all cases, "target" refers to an object in the "dictionary of 
> values" or "bag of properties" sense. "source" can be any kind of 
> object that has own properties.
>
> Object.define( target, source ): defineProperties w/ sensible defaults 
> (w, e, c: true).
>
> Object.put( target, source ): is... "put"! 
> (https://gist.github.com/3350283)

Some questions:

1. Why implicitly bind any function value?

2. Ditto for get and set accessor functions?

3. Why Object.defineProperty if !(key in target)? Why not just always 
assign, since this is Object.put and not Object.define?

/be


More information about the es-discuss mailing list