javascript合并两个对象

var a ={"name":"kobe"};

var b= {"age":20};


var c = Object.assign(a,b);

//a={"name":"kobe","age":20}

//c={"name":"kobe","age":20}



var a = {"name": "kobe"};
var b = undefined;
var c = Object.assign(a, b);
//a={"name":"kobe"}
//c={"name":"kobe"}
 
  


你可能感兴趣的:(js)