我有以下代码,其中传递数组长度太高并且处理每个数组元素需要一秒钟的时间,我如何在以下条件下使用工作线程?
function processData(arr){
var result = [];
for(var i = 0; i < arr.length; i++){
result.push(process(arr[i]));
}
return result;
}
function process() {
// some code here takes 1 second to execute
}
processData(arr);