$.extend
In general, when using depth to expand two objects, the effect we want is that the B object overrides all the attributes that exist in the A object, and none is added to the A object;
Let's take a look at the problems I've encountered:
I hope that the editoption in TMP will be covered by the deep expansion of the editoption in the RET, so the depth extension method is adopted ret = $.extend (true,{},ret,tmp);
But the result didn't work out the effect I wanted:
The length of the array in the object properties is still unchanged.
The example shows that although the array length has not changed, the value of the first 8 bits in the array is changed, that is to say, the variable depth extension overrides the value of the array, rather than overwriting the entire array object.
Note If you use $.extend (A, B) directly, the A object value is changed. Notice the Magic bug that the object reference throws
Because $.extend (A, A, a, b) returns a result after merging a with a, the A object will be changed.
Finally I use $.extend ({},a,b) to solve this requirement: that is, I do not change the reference of a A, B object, and I return the value I want.
Summary: Even simple methods, but also need to understand deeply, to avoid the subconscious cognitive interference in the judgment of things.
$.extend (true,{},a,b), deep understanding, beware of traps