首页 > 代码库 > jQuery深层次复制对象

jQuery深层次复制对象

<script type="text/javascript" src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
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);

jQuery深层次复制对象