get-nested-obj
v1.4.0
Published
safely get a nested object
Downloads
8
Readme
get-nested-obj
Intro
- safely get a nested object
Sample
var getNestedObj = require("get-nested-obj");
var test =
{
level1:
{
level2:
{
level3:'i am here'
}
}
};
console.log(getNestedObj(test, 'level1', 'level2', 'level3')); // 'i am here'
console.log(getNestedObj(test, 'level1', 'level2', 'foo')); // null
console.log(getNestedObj(test, 'list', '0', 'itemA')); // 'aa'
console.log(getNestedObj(null, 'level1', 'level2', 'foo')); // null
Author
Otto Mao [email protected]