Tweakr
    Preparing search index...

    Function set

    • Sets a value at the given path of an object, creating nested objects if necessary.

      Parameters

      • obj: any

        The target object.

      • path: string

        Dot-separated string path where the value should be set.

      • value: any

        The value to set at the specified path.

      Returns void

      const obj = {};
      set(obj, "a.b.c", 42);
      console.log(obj); // { a: { b: { c: 42 } } }

      1.1.0