Skip to main content

mergeDeep

Deep-merge multiple objects.

Inputs

Any non-complex objects.

Return

Returns a new object with the merged properties.

Limitations

  1. Provided objects will not be changed.
  2. Arrays inside the object will not merge. They will be overwritten.
  3. Objects cannot be complex.

Example

const o1 = {
    "a": 1,
    "b": 2
}

const o2 = {
    "c": 3,
    "d": 4,
    "e": {
        f: 5
    }
}

const merged = fyzUtils.mergeDeep(o1, o2);

const merged1 = merged.a;
const merged2 = merged.e.f;