const user = {
name: 'John',
age: 30,
city: 'NY'
};
const list = [];
for (const key in user) {
//console.log(key, user[key]); // name John, age 30, city NY
list.push(key, user[key]);
}
 
console.log(list);
 
const newlist = {};
 
for (const key in user) {
newlist[key] = user[key];
}
 
console.log(newlist);
Code will run automatically after changes.
Code runs in an isolated environment.