-1
我想用一個for在oop中獲取所有屬性的值,但不知道如何。 我在下面的教程給出了我如何做到這一點的例子,但我不明白這一點。如何在javascript中打印對象中所有屬性的值?
for(var x in dog) { console.log(dog[x]); }
var nyc = {
fullName: "New York City",
mayor: "Michael Bloomberg",
population: 8000000,
boroughs: 5
};
// write a for-in loop to print the value of nyc's properties
我知道這個代碼在狗(VAR X ){console.log(dog [x]); } –
你的Javascript書是什麼意思? –
在nyc中打印每個屬性的值用於循環 –