Function: getNestedValue()
function getNestedValue(obj, path): any;
Gets a nested value from an object using dot or PHP-style bracket notation.
Parameters
Parameter | Type | Description |
---|---|---|
obj | any | The object to traverse. |
path | string | The path string (e.g. 'a.b.c' or 'a[b][c]'). |
Returns
any
The value at the nested path, or undefined if not found.
Example
getNestedValue(obj, 'a.b.c')
getNestedValue(obj, 'a[b][c]')