robert_hly

踩坑填坑记录...

导航

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);

posted on 2016-12-28 19:46  robert_hly  阅读(179)  评论(0编辑  收藏  举报