javascript - Merge two objects and overwrite the values if conflict -


i'm trying merge 2 objects , overwrite values in process.

is possible underscore following? (i'm fine not using underscore want simple)

var obj1 = {     "hello":"xxx"     "win":"xxx" };  var obj2 = {     "hello":"zzz" };  var obj3 = merge(obj1, obj2);  /*  {     "hello":"zzz",     "win":"xxx" }  */ 

use extend:

 var obj3 = _.extend({}, obj1, obj2); 

the first argument modified, if don't want modify obj1 or obj2 pass in {}.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -