Tweakr
    Preparing search index...

    Function get

    • Safely retrieves a nested property from an object using a dot-separated path.

      Parameters

      • obj: any

        The object to query.

      • path: string

        Dot-separated path string (e.g., "a.b.c").

      • OptionaldefaultValue: any

        Value to return if the path is not found.

      Returns any

      The value at the specified path or the defaultValue if not found.

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

      const missing = get(obj, "a.b.x", "default");
      console.log(missing); // "default"

      1.1.0