0
var nyc = {
    fullName: "New York City",
    mayor: "Michael Bloomberg",
    population: 8000000,
    boroughs: 5
};

var myProperty = this.nyc;
/*this is one variable so how can it store all the values and what does this.nyc mean
and what value it carries, value of all property or just the value of one property*/
for(myProperty in nyc){console.log(nyc[myProperty]);}
//how is this line giving me the value of all the properties of object.

基本上 for in 循环是如何工作的?

4

1 回答 1

1

myProperty在循环的每次迭代中设置为一个新值for。所以旧值myProperty无关紧要。

于 2012-02-16T07:19:01.627 回答