Gets the data at path in object. Assumes '.' separates each segment of path.
path
object
getField({ name: { first: `Thom`, last: `Yorke` }}, `name.first`); // 'Thom'getField({ colours: [`red`, `green`, `blue` ]}, `colours.1`); // `green` Copy
getField({ name: { first: `Thom`, last: `Yorke` }}, `name.first`); // 'Thom'getField({ colours: [`red`, `green`, `blue` ]}, `colours.1`); // `green`
Returns undefined if path could not be resolved.
Throws if:
Gets the data at
path
inobject
. Assumes '.' separates each segment of path.Returns undefined if path could not be resolved.
Throws if:
path
is not a string or emptyobject
is undefined or null