Summary of $.extend () usage.
jquery has two methods for developing Plug-ins, respectively:
JQuery.fn.extend (object);
Jquery.extend (object); Jquery.extend (object); To extend the jquery class itself. Adds a new method to the class.
JQuery.fn.extend (object); Add methods to the JQuery object. This should be very well understood. Give an example.
<span style= "FONT-SIZE:18PX;" >
OK, so you've seen a little bit of $.extend ().
1. Merge multiple objects.
This is the function of nesting multiple objects for $.extend ().
Nesting multiple objects is a bit like an array-merging operation.
But this is the object. An example is provided.
<span style= "FONT-SIZE:18PX;" >//usage: jquery.extend (obj1,obj2,obj3,..)
var css1={size: "10px", Style: "Oblique"}
var css2={size: "12px", Style: "Oblique", Weight: "Bolder"}
$. Jquery.extend (CSS1,CSS2)
//Result: The Size property of Css1 is overwritten and inherits Css2 weight attribute
//Css1 = {size: "12px", Style: "Oblique", Weight: "Bolder"}
</span>
2. Deep nested objects.
<span style= "FONT-SIZE:18PX;" > jquery.extend (
{name: "John", Location: {City: "Boston"}},
{last: "Resig", Location: {state: "MA"} }
);
Result:
//=> {name: "John", Last: "Resig", Location: {state: "MA"}}
//New deeper. Extend ()
jquery.extend ( True,
{name: ' John ', location: {city: ' Boston '}},
{last: ' Resig ', location: {state: "MA"}}
);
Result
//=> {name: ' John ', Last: ' Resig ',
// location: {city: ' Boston ', State: ' MA '}}
</span >
3. You can add a static method to jquery.
<span style= "FONT-SIZE:18PX;" >
Best Wishes