AmpersandJS / amp

a collection of individual JS utility modules
http://amp.ampersandjs.com
MIT License
130 stars 12 forks source link

adding merge function #58

Closed rtorr closed 9 years ago

rtorr commented 9 years ago

@mattwondra also inspired this.

This merge function will give an easy way to combine objects, like extend, but will return a new object, rather than change the destinationObject.

HenrikJoreteg commented 9 years ago

any thoughts on this method from @AmpersandJS/core-team ?

lukekarrys commented 9 years ago

I like it. It's simple but there are often times in code when I want to express that I'm trying to do something different than extending an existing object. I'm a fan of this over extend({}, obj, obj1) since it's being more explicit.

+1

rtorr commented 9 years ago

@lukekarrys that is exactly our use case at work. We have parts of our code that we always want "merge". It betters the chance of being more clear and not leaving room for the mistake of leaving out the first object. We already implemented this in our project, and thought it might be useful.

HenrikJoreteg commented 9 years ago

agreed, i like to too, let's do it.