Javascript-遍历函数数组

此提取循环遍历一系列将值返回给HTML元素的函数。

htmlElementArray = ["averageCon", "medianCon", "SDCon"];
functionArray = [findAverageFunction, findMedianFunction, findSDFunction];

for (i=0;i<htmlElementArray.length;i++) {
    document.getElementById(htmlElementArray[i]+"1").innerHTML = functionArray[i](inCon1);
    document.getElementById(htmlElementArray[i]+"2").innerHTML = functionArray[i](inCon2); //<---
}

But an error says functionArray[i] is not a function at the indicated line but not at the previous one. Could you explain why?

谢谢。

评论