The extend method of jQuery and the jQueryextend Method
Extend in jq is often asked during interviews. Today I will summarize three methods of extend usage comparison, which may be incomplete. I hope you can give me some advice,
Usage 1: $. extend ({}),Add a method for the jQuery class, which can be understoodExtensionStatic Method
Usage 2: $. fn. extend ({}) plug-in,Extension of jQuery. prototype. When it comes to plug-ins, you have to talk about another method.$. Fn. method = function (){}
1.$. Fn. method = function () {} can define a method.
2.$. Fn. extend ({}) defines multiple methods.
It must be instantiated: $ (). toChange (), so its prototype method can be used.
$. Extend ({}) -- Static Method and$. Fn. extend ({}) -- Differences Between instance methods. $ is short for jQuery.
1:The call of jQuery. extend () does not extend the method to the instance of the object. The method to reference it also needs to be implemented through the jQuery class.
2:The call of jQuery. fn. extend () extends the method to the prototype of the object. Therefore, when instantiating a jQuery object, it has these methods,
3: jQuery. fn. extend = jQuery. prototype. extend
Usage 3: Inherit. Shallow copy and deep copy
1. Copying $. extend (a, B) a using B's attributes
2. Deep copy $. extend (true, a, B) a uses B's attributes
3.No matter how many objects follow, it will become the attribute of the first object.