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

c - sscanf() double showing zeros -

command line - Python: find current directory of remote "cmd.exe" processes -

pentaho - Carte Status / Kettle Slave Server Status page shows status for random runs instead of the latest run -