kjessec / dotprop

Get property value by string dot notation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dotprop Build Status

Get property by dot notation. A short and dependable implementation.

var getProp = require('dotprop');

getProp({a: { b: { c: 1}} }, 'a.b.c') // 1
getProp([1,2,3], 2) // 3
getProp({}, 'a.b') // undefined

// recognizes arrays too
getProp({a: { b: { c: 1}} }, ['a', 'b', 'c']) // 1
getProp({a: { 'b.c': 1 }}, ['a', 'b.c']) // 1

Similar

NPM

About

Get property value by string dot notation

License:MIT License


Languages

Language:JavaScript 100.0%