I want to merge two objects without cloning or mutating one of them.
function merge(defaultOptions, userOptions) {
// userOptions should not be cloned or mutated but should get priority over defaultOptions
return res;
}
I am using lodash but _merge does not help much. Since userOptions can be huge, I want to avoid cloning it.
Note that it is alright to mutate or clone defaultOptions as it would not affect performance of my system.
What is an optimal way to do this?