0
var ppArr []; // An Array filled with Objects
var ppSort []; // Empty Array
var i = 0; // Counter
for (; ; i++) // Increase "i"
if (...) // does not matter here
{
var ppInfo = { SortIndex : ppArr[i].SortIndex, PPCount : 1, SortedArr : newArray() };
ppInfo.SortedArr.push(ppArr[i]);
ppSort.push(ppInfo);
}
else { // Neither dose that part
...
}
}
https://repl.it/E4xO/19如何訪問數組中的對象的屬性?
你好專家,
我有通過在Javascript數組訪問一個對象的屬性的問題。
正如您所看到的,我正在將「ppInfo」對象注入名爲「ppSort」的空數組中。
如何訪問此對象的SortIndex?
我曾嘗試以下:
- ppSort.ppInfo.SortIndex
- ppSort [I] .ppInfo.SortIndex
我不知道還有什麼我可以試試。我在做一些錯誤的事嗎? 我可以通過「ppInfo.SortIndex」訪問SortIndex,但每次運行後都會更改此對象。
謝謝你,最好的問候,
'ppSort [I] .SortIndex' –
請你把這個最小您的問題的重新創建。目前'ppArr'中沒有對象,因此我們無法判斷您無法訪問其內容的屬性。 (另外,修復你的縮進:目前不清楚你的代碼的結構是什麼意思。) – Richard
@Ori Drori它返回「undefined」 – Wintersun