Function DeepGet

    • Retrieves a value from a nested object using a dot notation key.

      This function will never throws any error if there is a problem with the input type. It will return undefined instead. This also means that if the key is not found, the function will return undefined instead of null especially when working on JSON data.

      Parameters

      • obj: { [key: string]: any }

        The object from which the value is to be retrieved.

      • key: string

        The key in dot notation representing the path to the value.

      • Optionaloptions: { sep: string }

        Optional settings.

        • sep: string

          Custom key separator (default: '.').

      Returns any

      The value at the specified key if it exists, or undefined if the key is not found or an error occurs.

      const obj = { a: { b: { c: 42, d: { _: 'foo' } } } };
      getValue(obj, 'a.b.d._'); // foo
      const obj = { a: { b: { c: [1, 2, 3] } } };
      getValue(obj, 'a.b.c[1]'); // 2

      1.0.0

    Properties

    Properties

    DEFAULT_SEP: "."