@noname-land/get
Returns the value in a nested object, by string-sequence of keys.
Returns undefined
if the key is not present, or the default value
if supplied.
Installation
npm i --save @noname-land/get
Usage
import get from '@noname-land/get';
const obj = {
a: 1,
b: 2,
c: {
d: 1,
e: 2,
f: {
g: 1,
h: 2,
i: 3,
},
},
};
console.log(get(obj, 'c.f.i')); // 3
console.log(get(obj, 'c.f.i.j')); // undefined
console.log(get(obj, 'c.f.i.j', 1)); // 1