$.extend():作为扩展工具方法
$.extend({
aaa:function(){
alert(123);
},
bbb:function(){
alert(456);
}
})
$.aaa();
$.bbb();
$.fn.extend():作为jQ的实例方法
$.fn.extend({
aaa:function(){
alert(123);
},
bbb:function(){
alert(456);
}
})
$().aaa();
$().bbb();
深拷贝和浅拷贝
var a = {}
var b = {name:'hello'}
$.extend(a,b);
a.name = 'hi';
console.log(b.name);//hello
//浅拷贝
var a = {}
var b = {name:{age:'hello'}}
$.extend(a,b);
a.name.age = 'hi';
console.log(b.name.age);//hi
//深拷贝
var a = {}
var b = { name:{age:'hello'}}
$.extend(true,a,b);
a.name.age = 'hi';
console.log(b.name.age);//hello
var aa = {}
$.extend(a,{b:'123'})