var nyc = {
fullName: "New York City",
mayor: "Bill de Blasio",
population: 8000000,
boroughs: 5
};
for(var i in nyc){
console.log(i);
}
输出:
//输出的是属性
var nyc = {
fullName: "New York City",
mayor: "Bill de Blasio",
population: 8000000,
boroughs: 5
};
fullName: "New York City",
mayor: "Bill de Blasio",
population: 8000000,
boroughs: 5
};
// write a for-in loop to print the value of nyc's properties
for(var i in nyc){
console.log(nyc[i]);
}
输出:
//输出了属性的内容