String object notation to value reference
•
1 min read
Here the cleanest way to get the object value from a string representation of the dot notation path:
const key = 'a.b.c'
const ob = {a: {b: {c:true}}}
const prop = key.split('.').reduce((o, i) => o[i], ob)