getNestedValue()
Function: getNestedValue()
Section titled “Function: getNestedValue()”function getNestedValue(obj, path): any;Gets a nested value from an object using dot or PHP-style bracket notation.
Parameters
Section titled “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
Section titled “Returns”any
The value at the nested path, or undefined if not found.
Example
Section titled “Example”getNestedValue(obj, 'a.b.c')getNestedValue(obj, 'a[b][c]')