getObjectValueByPath
Commons
stable
Resolves a dot-notation (or bracket-notation) path string against an object and returns the found value, or a fallback when null or absent.
API
Signature
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- objrequiredany
- The root object to traverse. Returns fallback immediately when null or undefined.
- pathstring | null
- A dot-separated property path (e.g. "user.profile.name") or bracket notation (e.g. "items[0].value"). Leading dots and bracket indices are normalised automatically.
- fallbackany
- Value returned when the path cannot be resolved. Defaults to undefined.
API
Return value
The value returned by this util.
- The value found at the specified path, or the fallback.
Usage
Examples
Ready-to-paste usage snippets.
Dot-path and bracket-path traversal