In the process of using jquery, Extend is a commonly used parameter processing function, especially for default values.
The extension method prototype for jquery is:
var v=$.extend (DEST,SRC1,SRC2,[,SRC3 ...]);
The effect is to merge the SRC1,SRC2,SRC3 into the Dest and return the merged dest.
But in the process of using, the default value is often cannot be changed,
As follows:
var defaut={' selector ': ' SELECT ', ' Default ': ' Defaults ', ' BackColor ': ' #85e137 ', ' ForeColor ': ' #000 '};
var src={' selector ': ' ss ', ' Default ': ' Jokes ', ' BackColor ': ' #fff ', ' ForeColor ': ' Red '};
If we use
var v=$.extend (DFAULT,SRC);
To handle the parameters, the default value for the next processing is the value after this process rather than the actual default value.
We can use the following code:
var v=$.extend ({},dfault,src);
That is, we use an empty object as the target parameter (default), the default parameter as the first source parameter (SRC), which also returns the merged parameters, but our default is not changed and can be used again!
This enables the default value to remain the same effect!