我想一個數組傳遞給一個對象:將數組傳遞給一個對象在JS
function process(pid, size, time, IOCArray, IOCtimeA, status) {
this.pid = pid;
this.size = size;
this.time = time;
this.IOCtimeA = IOCtimeA; // should i use this?
for (var j = 0; j < IOCArray.length; j++) {
this.IOCArray[j] = IOCArray[j];
} // or something like this?
this.status = status;
}
proarray[ID] = new process(ID, size, time, IOCArray, IOCtimeA, status);
現在,我怎麼能訪問例如proarray[5].IOCArray[4]
? 其實我不知道如何使用「this」作爲數組。
你可以只是做'this.IOCArray = IOCArray.slice(0);'? – adeneo 2014-12-06 16:51:47
你有沒有試過用'proarray [5] .IOCArray [4]'來說話?你有什麼錯誤嗎? – abl 2014-12-06 16:53:49
@adeneo謝謝你...它的工作 – 2014-12-06 17:03:18