jQuery.extend function introduction
JQuery.extend Extension method:
Extension method of jQuery extend is usually method when write plugin,
一、jquery prototype method
it mean merge src1 src2 src3 into dest,result is dest merged,It can be seen that after according to methods ,the dest already modify。if you want't get modified dest,you can use :
So you can merge SRC1, src2, src3...。
for example:
and result is
It meas the later element will cover front element
二、omit dest
for example:
1、$.extend(src)
the way can merge the attribution into jquery object:
hello:function(){alert('hello');}
});
2、$.fn.extend(src)
the way can merge the attribution into jquery prototype:
hello:function(){alert('hello');}
});
list some example under:
this is way that can extent net space in jquery global objec
hello:function(){alert('hello');}
})
三、Jquery.extend方法also have one prototype:
first params boolean is represent whether if deep copy,for example:
{ name: "John", location: {city: "Boston",county:"USA"} },
{ last: "Resig", location: {state: "MA",county:"China"} } );
we can seen object of src1 location:{city:"Boston"},object of src2 location:{state:"MA"},merge result is::
location:{city:"Boston",state:"MA",county:"China"}}
so it will merge nested object in src,if first boolean is false,we look ,for example:
{ name: "John", location:{city: "Boston",county:"USA"} },
{ last: "Resig", location: {state: "MA",county:"China"} }
);
result is: