get-property-value

get the property value from a nested js object by using a dot path `a.b.c`

ISC License

Downloads
3K
Stars
4
Committers
2

get-property-value

get the property value from a nested object by using a dot path a.b.c

API

var getPropValue = require('get-property-value')

getPropValue({}, 'path')

Usage


var getPropValue = require('get-property-value')

var obj = {a: {b: 1}, c: {d: {f: 'hello'}}}

var fValue = getPropertyValue(obj, 'c.d.f')// hello
var aValue = getPropertyValue(obj, 'a')// {b: 1}

var propNotExist = getPropertyValue(obj, 'c.d.g') // undefined

var badObject = getPropertyValue('hello', 'c.d.g') // hello

var badPath = getPropertyValue({a: 1})// {a: 1}

ISC License (ISC)

Package Rankings
Top 6.94% on Npmjs.org
Badges
Extracted from project README
Build Status ISC License NodeJS
Related Projects