JSFiddle - React, Tailwind, and code Playground
by evgkch
JavaScript
const getProp = (target, [firstProp, ...restProps] = []) =>
firstProp
? target[firstProp]
? getProp(target[firstProp], restProps)
: target[firstProp]
: target;
console.log(getProp({}, ['as']))