# getProp

Function

Get a property out of a deeply nested object. Supports array indexing and property matching.

Examples:

``````getProp({a: {b: {c: 1}}}, "a.b.c") => 1
getProp({a: {b: {c: 1}}}, "a.b.d") => undefined
getProp({a: {b: {c: 1}}}, "a.b") => {c: 1}
getProp({a: {b: [1,2]}}, "a.b[0]") => 1
getProp({a: {b: {c: 1}, b2: { \$use: "a.b"}}, "a.b2") => {c: 1}
getProp({a: [{key: "x", val:1}, {key: "y", val:3}]}, "a[1]") => {key: "y", val:3}
getProp({a: [{key: "x", val:1}, {key: "y", val:3}]}, "a[1].val") => 3
getProp({a: [{key: "x", val:1}, {key: "y", val:3}]}, "a[findBy(key,y)].val") => 3
getProp({a: [{key: "x", val:1}, {key: "y", val:3}]}, "a[findBy(val,1)].key") => "x"
``````

Get a property out of a deeply nested object. Supports array indexing and property matching.

Examples:

``````getProp({a: {b: {c: 1}}}, "a.b.c") => 1
getProp({a: {b: {c: 1}}}, "a.b.d") => undefined
getProp({a: {b: {c: 1}}}, "a.b") => {c: 1}
getProp({a: {b: [1,2]}}, "a.b[0]") => 1
getProp({a: {b: {c: 1}, b2: { \$use: "a.b"}}, "a.b2") => {c: 1}
getProp({a: [{key: "x", val:1}, {key: "y", val:3}]}, "a[1]") => {key: "y", val:3}
getProp({a: [{key: "x", val:1}, {key: "y", val:3}]}, "a[1].val") => 3
getProp({a: [{key: "x", val:1}, {key: "y", val:3}]}, "a[findBy(key,y)].val") => 3
getProp({a: [{key: "x", val:1}, {key: "y", val:3}]}, "a[findBy(val,1)].key") => "x"
``````
• getProp(obj: [key: string]: any , path: string) : any

## Parameters

Parameter Type Default Notes
obj Required [key: string]: any
path Required string

## Returns

any

Function defined in common/src/objects/get-prop.ts:18