jQuery.extend extends a target object with properties from other objects and it’s widely used in every piece of jQuery code.
Really it’s very useful and simple to undestand and use for flat properties.
{[ .extend-flat | @how-to-highlight-code-in-wordpress.hilite( =javascript= ) ]}
On the contrary, if the involved objects have object properties, jQuery.extend is less intuitive and less useful too.
{[ .extend-object | @how-to-highlight-code-in-wordpress.hilite( =javascript= ) ]}
Luckily, an undocumented feature (deep) makes jQuery.extend recurr object properties.
{[ .extend-deep-std | @how-to-highlight-code-in-wordpress.hilite( =javascript= ) ]}
Unluckily, deep only works for the first level. (not really a ‘bug’)
{[ .extend-deep-bug | @how-to-highlight-code-in-wordpress.hilite( =javascript= ) ]}
If you need deep recursion use jQuery.extend_deep instead.
{[ .extend-deep-fix | @how-to-highlight-code-in-wordpress.hilite( =javascript= ) ]}
Here is the jQuery.extend_deep plugin:
{[ .extend-deep-plugin | @how-to-highlight-code-in-wordpress.hilite( =javascript= ) ]}