我正在尝试使用jQuery $.extend合并两个对象。
使用以下代码,我想要弹出(“Ball - Stump - Umpire”)。但当前输出为(“Undefined - Stump - Umpire”)。它没有实现深层(递归)复制。我们如何纠正这个问题?
$(document).ready(function () {
debugger;
//$.extend
var obj3 = { throwable: { text1: 'Ball' }, text3: 'Umpire' };
var obj4 = { throwable: { text4: 'Bat' }, text2: 'Stump' }
//Simple Copy
var result1 = $.extend(obj3, obj4);
//alert(result1.throwable.text4 + " - " + result1.text2 + " - " + result1.text3);
//Deep Copy
//First parameter is passed as Boolean true to accomplish deep (recursive) copy
var result2 = $.extend(true, obj3, obj4);
alert(result2.throwable.text1 + " - " + result2.text2 + " - " + result2.text3);
});
编辑:我提到
asp.net
,.net
,jquery-ui
,jquery-plugins
,与问题有什么关联? - gdoron