Object.assign and __proto__ property

Nathan Wall nathan.wall at live.com
Mon Oct 21 20:58:38 PDT 2013


Rick Waldron wrote:
> If this were how it was defined, I would say get rid of it and 
> practitioners will carry on using their own non-nanny implementations. 
> If it can't invoke setters then it loses properties like innerHTML. 
> 
> eg. 
> 
> Object.assign(div, { 
> innerHTML: `${name}<BR>`, 
> id: "an-id", 
> dataset: { 
> foo: 1, 
> bar: 2 
> } 
> }); 
> 
>

I see.  I wasn't clear on the use-case for `Object.assign`.  You're right; this makes sense.

Given this use for `Object.assign`, integrity probably isn't a concern for these cases.  A lot of the times, you'll know where the data's coming from, and if you don't you can filter it.  Looks like a nice short-hand (though I'm still somewhat hoping for monocle-mustache in a later edition!)  I was thinking of it too much as a cousin to `Object.mixin`, which is great for meta-programming and building abstractions.  `Object.assign` seems more geared toward being a nice little helper function.

Cool,

Nathan 		 	   		  


More information about the es-discuss mailing list