我有一點麻煩的循環讀取數組:Javascript數組循環變量未定義
var myStringArray = [{
"people": [{
"id": "123",
"name": "name 1"
}, {
"id": "456",
"name": "name 2"
}]
}];
var arrayLength = myStringArray.length;
for (var i = 0; i < arrayLength; i++) {
console.log(myStringArray[i].id);
}
我要去哪裏錯了嗎?
你不夠深刻......'myStringArray [0] .people [i] .id'。 ;) – evolutionxbox
和'var arrayLength = myStringArray [0] .people.length'; – taguenizy