Tweakr
    Preparing search index...

    Function deepMerge

    • Recursively merges properties of the source object into the target object. Nested plain objects are merged, while arrays and primitive values are replaced.

      Type Parameters

      • T extends object
      • U extends object

      Parameters

      • target: T

        The target object to merge into.

      • source: U

        The source object whose properties will be merged.

      Returns T & U

      A new object containing merged properties from both target and source.

      const obj1 = { a: 1, b: { x: 10 } };
      const obj2 = { b: { y: 20 }, c: 3 };
      const merged = deepMerge(obj1, obj2);
      console.log(merged); // { a: 1, b: { x: 10, y: 20 }, c: 3 }

      1.1.0