var obj1 = { 'a': 's1', 'b': [1,2,3,{'a':'s2'}], 'c': {'a':'s3', 'b': [4,5,6]}}var obj2 = $.extend(true, {}, obj1);obj2.a='s1s1';obj2.b[0]=100;obj2.c.b[0]=400;console.log(obj1);console.log(obj2);
本文共 249 字,大约阅读时间需要 1 分钟。
var obj1 = { 'a': 's1', 'b': [1,2,3,{'a':'s2'}], 'c': {'a':'s3', 'b': [4,5,6]}}var obj2 = $.extend(true, {}, obj1);obj2.a='s1s1';obj2.b[0]=100;obj2.c.b[0]=400;console.log(obj1);console.log(obj2);
转载于:https://www.cnblogs.com/exayong/p/6230692.html