const obj = {
something: {
something1: 'value',
something2: 'value1',
something3: {
something4: 'value2'
}
}
};
const obj = {
something: {
something1: 'value',
something2: 'value1',
something3: {
something4: 'value2'
}
}
}
const getKeys = obj => {
const res = []
for (const key in obj) {
res.push(key)
obj[key] && Object.getPrototypeOf(obj[key]) === Object.prototype && res.push(...getKeys(obj[key]))
}
return res
}
console.log(getKeys(obj))
//[ 'something', 'something1', 'something2', 'something3', 'something4' ]