В интернете ничего толкового найти не могу
const obj1 = {
foo: {
bar: {
value: 'final'
}
}
};
function getDeepKeys(obj) {
let keys = [];
for(const key in obj) {
keys.push(key);
if(typeof obj[key] === "object") {
const subkeys = getDeepKeys(obj[key]);
keys = keys.concat(subkeys.map(subkey => `${key}.${subkey}`));
}
}
return keys;
}
console.log(getDeepKeys(obj1)); // ["foo", "foo.bar", "foo.bar.value"]