get
@guoba-ai/utils / object / get
Function: get()
function get<T>(
obj,
path,
defaultValue?): T;Defined in: object.ts:285
Access a nested property by dot path.
Type Parameters
T
T = unknown
Parameters
obj
unknown
The object to access
path
string
Dot-separated path string (e.g. 'a.b.c')
defaultValue?
T
Value to return if the path does not resolve
Returns
T
The value at the path, or defaultValue if not found
Example
get({ a: { b: { c: 42 } } }, 'a.b.c') // 42
get({ a: 1 }, 'b.c', 'default') // 'default'