"DoctorA": {"name": "Pharmaceuticals", "title": "Switzerland, 120000 employees","type":"yes"},
"DoctorB": {"name": "Consulting", "title": "USA, 5500 employees","type":"yes"},
"DoctorC": {"name": "Diagnostics", "title": "USA, 42000 employees","type":"no"},
"DoctorD": {"name": "Fin Serv. & Wellness", "title": "South Africa, employees","type":"no"}
我正在使用data.speakers獲取它。如何只讀取此類型鍵值
我想得到每一個醫生類型,所以我試過這個。
for (property in data.speakers) {
//alert(property) contains all the doctor name.
//i want type for each doctor indivdually.
for (key in data.speakers) {
var doctor = data.speakers[key];
types.push(doctor.type);
}
alert(types.toSource());
}
有沒有什麼辦法讓this.It將返回數組形式的所有數據類型(是,否,是,否}我想這樣的,首先我會得到doctorA並獲取其類型是。。不
你有一個額外的循環水平,你不需要。 – Aesthete
你不需要2個循環,只有一個。 –
這些都是奇怪的變量名稱。你在數組'names'中放入'type'的值,可以是''yes''或''no''? –