l-safeget
v0.0.2
Published
get a nested value from an object by paths (`a.b.c` or ['a','b','c'])
Downloads
12
Readme
safeGet(obj,path)
get a nested value from obj by path like 'a.b.c' or ['a','b','c']
Install
npm install l-safeget -S
Usage
var safeGet = require("l-safeget");
var testData = { a: [{ c: { b: [233] } }] };
safeGet(testData,'a[0].c.b[0]') //=> 233
safeGet(testData,['a','0','c','b','0']) //=> 233