Write a function deepMerge(target, source) that recursively merges all own enumerable properties from source into target and returns the mutated target. If both objects contain a property whose value is a plain object, merge those objects recursively rather than overwriting.
function deepMerge(target, source) {
// your code here
}
Rules:
- Mutate and return the target object.
- Non-object values or arrays should be overwritten by the source value.
- Must handle nested objects of arbitrary depth.
Post your solution as a reply. Answer goes up in about a day.