Get property by dot notation. A short and dependable implementation.
import getProp from '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
- developit/dlv – the most compact alternative.
- sindresohrus/dot-prop - enables escaping
\.
at price of larger codebase. - facebookindicator/idx