const object = {a: 1, b: 2, c: {b: 3,w:4}};
for (const property in object) {
console.log(`${property}: ${object[property]}`)
}
function printKeys(object) {
for (const [ key, value ] of Object.entries(object)) {
if (value?.constructor.name === 'Object') {
printKeys(value);
} else console.log(key, value);
}
}
function printKeys(object, prefix = '') {
for (const [ key, value ] of Object.entries(object)) {
if (value?.constructor.name === 'Object') {
printKeys(value, `${prefix}${key}.`);
} else console.log(prefix + key, value);
}
}