This article mainly describes how to use the extend in jquery, need friends can refer to the following
In jquery, the Extend extension method prototype is: 1, Extend (dest,src1,src2,src3 ...); Its meaning is to src1,src2,src3 ... Merged into Dest, the return value is the merged dest, which shows that the method is modified to dest structure after merging. If you want to get the result of merging but do not want to modify the structure of dest, you can use: 2, var newsrc=$.extend ({},src1,src2,src3 ...) as follows. That is, "{}" as the Dest parameter. This will be able to src1,src2,src3 ... To merge, and then return the merge results to NEWSRC. The following example: code is as follows: Var result=$.extend ({},{name: "Tom", Age:21},{name: "Jerry", Sex: "Boy"}) then the merged result result={name: "Jerry", Age:21,sex: "Boy"} that is, if the following argument has the same name as the previous argument, then the previous parameter value will be overwritten. 3, Extend (BOOLEAN,DEST,SRC1,SRC2,SRC3 ...) The first parameter Boolean represents whether to make a deep copy, and the remaining parameters are consistent with the previous description For example code as follows: Var result=$.extend (True, {}, {name: "John", Loca tion: {City: "Boston", County: "The USA"}}, {last: "Resig", Location: {state: "MA", County: ""}); we can To see that the nested SRC1 in the location:{city: "Boston"},SRC2 also has a nested object location:{state: "MA"}, and the first depth copy parameter is true, then the result of the merge is the: code as follows: Result={name: "John", Last: "Resig", location:{city: "Boston", State:"MA", County: "China"}} that is, it will also merge the nested subforms in SRC, and if the first argument Boolean is false, let's see what the result of the merge is, as follows: code as follows : Var result=$.extend (false, {}, {name: "John", location:{city: "Boston", County: "USA"}}, {last: "Resig", L Ocation: {state: "MA", County: "" "; then the result of the merge is: code as follows: Result={name:" John ", Last:" Resig ", Location:{state: "MA", County: "}} "