So if you know it's going to be one level down, here is how you could list everything one level down:
Object.keys(user).forEach(item => {
Object.keys(user[item]).forEach(innerItem =>{
console.log(innerItem + ': ' + user[item][innerItem])
} )
})
If you know you want name then either you could adapt the above to have
if (innerItem == 'name'){ //or ===
console.log(innerItem + ': ' + user[item][innerItem])}
or as evolutionxbox commented:
Object.keys(user).forEach(item => {
console.log(user[item].name)}
)
On the other hand, if you want all simple properties, but you don't know how deep they will be, you can do the following adapted from traversing through JSON string to inner levels using recursive function
function scan(obj, propName) {
var k;
if (obj instanceof Object) {
for (k in obj){
if (obj.hasOwnProperty(k)){
//recursive call to scan property
scan( obj[k], k );
}
}
} else {
//obj is not an instance of Object so obj here is a value
console.log(propName+': '+ obj)
};
};
scan(user, 'top')
And if you know you want names only, block your console log as follows:
if (propName === 'name'){
console.log(propName+': '+ obj)}