jquery为开发插件提供了两个方法

// 补充知识点:jquery为开发插件提供了两个方法,方别为
//1、jQuery.fn.extend(object) ->给jquery对象添加方法 $('.ele').add()
//2、jQuery.extend(object)->给jquery类添加方法; $.add()

//2.1:
//$.extend()的嵌套多个对象功能,例如:
//var Css1={size: "10px",style: "oblique"}
// var Css2={size: "12px",style: "oblique",weight: "bolder"}
// $.jQuery.extend(Css1,Css2);
//结果:Css1的size属性被覆盖,而且继承了Css2的weight属性
// Css1 = {size: "12px",style: "oblique",weight: "bolder"}

//2.2:
//$.extend()深度嵌套对象
//{ name: “John”, location: { city: “Boston” } };
//{ last: “Resig”, location: { state: “MA” } };
// 结果:
// => { name: “John”, last: “Resig”, location: { state: “MA” } }
// 新的更深入的 .extend()
// jQuery.extend( true,
// { name: “John”, location: { city: “Boston” } },
// { last: “Resig”, location: { state: “MA” } }
// );
// 结果
// => { name: “John”, last: “Resig”,
// location: { city: “Boston”, state: “MA” } }

原文地址:https://www.cnblogs.com/sunqq/p/9910286.html