@lxfriday/get-object-value
v1.0.3
Published
get object inner value
Downloads
2
Readme
@lxfriday/get-object-value
get object inner value
install
npm i @lxfriday/get-object-value -S
# or
yarn add @lxfriday/get-object-value
params
smoothScrollTo(ref, pos[, rate])
obj
{object
}required
, target objectkeys
{array
}required
, key array, like object.a.b.c.d.e => ['a', 'b', 'c', 'd', 'e']defaultRet
{any
} if not found or error, will return defaultRet
usage
const obj = {
a: {
b: {
c: {
d: {
e: 'abcde',
},
},
},
},
}
// not found
console.log('result => ', secureGetValue(obj, ['a', 'b', 'c', 'd', 'e', 'f'], 'not found'))
// abcde
console.log('result => ', secureGetValue(obj, ['a', 'b', 'c', 'd', 'e'], 'not found'))