Deeply merges two objects, filling in undefined or missing properties from the source object into the target object. Nested objects are merged recursively. Existing values in the target object are preserved.
The source object containing the default values.
The target object to merge values into.
The merged target object.
const userSettings = { theme: { darkMode: true } };const defaultSettings = { theme: { darkMode: false, fontSize: 14 }, locale: 'en' };const merged = deepMerge(userSettings, defaultSettings);// merged: { theme: { darkMode: true, fontSize: 14 }, locale: 'en' } Copy
const userSettings = { theme: { darkMode: true } };const defaultSettings = { theme: { darkMode: false, fontSize: 14 }, locale: 'en' };const merged = deepMerge(userSettings, defaultSettings);// merged: { theme: { darkMode: true, fontSize: 14 }, locale: 'en' }
Deeply merges two objects, filling in undefined or missing properties from the source object into the target object. Nested objects are merged recursively. Existing values in the target object are preserved.