我想一个数组传递给一个对象:将数组传递给一个对象在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