Safely Read a Deeply Nested Object Property Using a Dot-Notation String Path

Implement a get(obj, path, defaultValue) function that accepts an object and a string path like 'a.b.c[0].d' and safely retrieves the nested value without throwing errors for missing intermediate keys. Return a provided default value if any segment is undefined or null. This is the core of lodash's _.get() and is heavily used in form libraries, state selectors, and configuration readers where deeply nested access is common.

Examples
Input: []
Output:
Hints

Safely Read a Deeply Nested Object Property Using a Dot-Notation String Path

Implement a get(obj, path, defaultValue) function that accepts an object and a string path like 'a.b.c[0].d' and safely retrieves the nested value without throwing errors for missing intermediate keys. Return a provided default value if any segment is undefined or null. This is the core of lodash's _.get() and is heavily used in form libraries, state selectors, and configuration readers where deeply nested access is common.