摘要: 如果我们希望实现“深复制”,当所复制的对象是数组或者对象时,就应该递归调用extend。如下代码是“深复制”的简单实现:$ = { extend : function(deep, target, options) { for (name in options) { copy = options[name]; if (deep && copy instanceof Array) { target[name] = $.extend(deep, [], copy); } else if (deep && copy instanceof Object) { target 阅读全文
posted @ 2011-08-18 14:27 ctou45 阅读(630) 评论(0) 推荐(0) 编辑
摘要: extend()函数是jQuery的基础函数之一,作用是扩展现有的对象。例如下面的代码:<script type="text/javascript" src="jquery-1.5.2.js"></script><script>obj1 = { a : 'a', b : 'b' };软件开发obj2 = { x : { xxx : 'xxx', yyy : 'yyy' }, y : 'y' };$.extend(true, obj1, ob 阅读全文
posted @ 2011-08-18 14:24 ctou45 阅读(245) 评论(0) 推荐(0) 编辑