dig
Gets the target value in a nested JSON object, based on the given key.
- Use the
inoperator to check iftargetexists inobj. - If found, return the value of
obj[target]. - Otherwise use
Object.values(obj)andArray.prototype.reduce()to recursively calldigon each nested object until the first matching key/value pair is found.