$.extend() copies properties from one or more source objects into a target object. It is the jQuery equivalent of the modern spread operator ({ ...defaults, ...options }) and is the standard pattern for implementing plugin option merging in jQuery code.
Shallow vs Deep Merge
By default $.extend(target, src) performs a shallow merge — nested objects are copied by reference, not recursively merged. Pass true as the first argument for a deep (recursive) merge: $.extend(true, target, src).
Plugin Options Pattern
When writing a jQuery plugin or a component constructor, define a defaults object and merge caller-supplied options over them. Using $.extend({}, defaults, options) — with an empty object as the first argument — creates a fresh object without mutating either defaults or options.
$.extend(target, src)— shallow merge into target$.extend(true, target, src)— deep recursive merge$.extend({}, defaults, options)— safe, non-mutating merge- Returns the merged target object