Safely retrieves a nested property from an object using a dot-separated path.
The object to query.
Dot-separated path string (e.g., "a.b.c").
Optional
Value to return if the path is not found.
The value at the specified path or the defaultValue if not found.
const obj = { a: { b: { c: 42 } } };const value = get(obj, "a.b.c");console.log(value); // 42const missing = get(obj, "a.b.x", "default");console.log(missing); // "default" Copy
const obj = { a: { b: { c: 42 } } };const value = get(obj, "a.b.c");console.log(value); // 42const missing = get(obj, "a.b.x", "default");console.log(missing); // "default"
1.1.0
Safely retrieves a nested property from an object using a dot-separated path.