Как эта программа получила мне значения свойства объекта? - PullRequest
0 голосов
/ 16 февраля 2012
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.

Как работает в основном для цикла?

1 Ответ

1 голос
/ 16 февраля 2012

myProperty устанавливается на новое значение на каждой итерации цикла for.Поэтому старое значение myProperty не имеет значения.

...