JQ extend in the interview will often be asked, today I summarized a under the use of the extend three kinds of comparison, may not be full, I hope everyone pointing,
usage One: $.extend ({}) , adding methods for jquery classes that can be understood as extending static methods
Usage Two:$.fn.extend ({}) plugin , extend to Jquery.prototype, mention plug-in then you have to say another method $.fn.method = function () {}
1. $.fn.method = function () {} can define a method
2. $.fn.extend ({}) defines multiple methods.
need to instantiate: $ (). Tochange (), then its prototype method can be used
$.extend ({})--static method and $.fn.extend ({})--The difference between instance methods, $ is shorthand for jquery
The call to 1:jquery.extend () does not extend the method to an instance of an object, and the method that references it also needs to be implemented through the JQuery class
The call to 2:jquery.fn.extend () extends the method to the prototype of the object, so when instantiating a JQuery object, it has these methods,
3:jquery.fn.extend = JQuery.prototype.extend
Usage three: Inherit. Shallow copy and deep copy
1. Shallow copy $.extend (A,B) a uses the properties of B
2. Deep copy $.extend (TRUE,A,B) a uses the properties of B
3. The properties of the first object, regardless of the number of objects behind it
The above is the entire content of this article, I hope the content of this article for everyone's study or work can bring some help, but also hope that a lot of support cloud Habitat community!