有没有办法将数组中的每个元素直接映射到单独的函数中,并将每个函数的结果返回到该元素的单独变量中?
例如,我有这个代码:
arry = ["22-03-1995", 80.5, 1.83];
born = process_date(arry[0]); // call specific function for 1st element
weight = process_weight(arry[1]); // call specific function for 2nd element
height = process_height(array[2]); // call specific function for 3rd element
...
function process_date(d) { ... }
function process_weight(w) { ... }
function process_height(h) { ... }
或这种替代方法以更好的更短形式实现相同的目的。
慕姐8265434
墨色风雨
慕妹3242003
相关分类