JSFiddle - React, Tailwind, and code Playground
by brigand
JavaScript
function foo(obj) {
const result = fooInternal(obj, []);
console.log(result);
return result;
}
function fooInternal(obj, path) {
if (obj) {
const key = Object.keys(obj)[0];
return fooInternal(obj[key], path.concat([key]));
} else {
return path;
}
}
foo({ a: { b: { c: null }}})