优化这段代码 tableParams = getenumeration(tableParams,"apl_drope_toxic_iipf_opea_mode"); tableParams = getenumeration(tableParams,"apl_per_entmgr_sex"); tableParams = getenumeration(tableParams,"apl_per_quamgr_sex"); tableParams = getenumeration(tableParams,"apl_per_purchase_sex"); tableParams = getenumeration(tableParams,"apl_per_custodian_sex"); tableParams = getenumeration(tableParams,"apl_per_sales_sex"); tableParams = getenumeration(tableParams,"apl_per_entmgr_edu"); tableParams = getenumeration(tableParams,"apl_per_quamgr_edu"); tableParams = getenumeration(tableParams,"apl_per_purchase_edu"); tableParams = getenumeration(tableParams,"apl_per_custodian_edu"); tableParams = getenumeration(tableParams,"apl_per_sales_edu"); tableParams = getenumeration(tableParams,"apl_per_entmgr_jobtitle"); tableParams = getenumeration(tableParams,"apl_per_quamgr_jobtitle"); tableParams = getenumeration(tableParams,"apl_per_purchase_jobtitle"); tableParams = getenumeration(tableParams,"apl_per_custodian_jobtitle"); tableParams = getenumeration(tableParams,"apl_per_sales_jobtitle");
时间: 2023-11-27 08:54:06 浏览: 69
优化代码
可以使用循环来优化这段代码,避免重复的调用 getenumeration() 函数:
```
const paramsList = [
"apl_drope_toxic_iipf_opea_mode",
"apl_per_entmgr_sex",
"apl_per_quamgr_sex",
"apl_per_purchase_sex",
"apl_per_custodian_sex",
"apl_per_sales_sex",
"apl_per_entmgr_edu",
"apl_per_quamgr_edu",
"apl_per_purchase_edu",
"apl_per_custodian_edu",
"apl_per_sales_edu",
"apl_per_entmgr_jobtitle",
"apl_per_quamgr_jobtitle",
"apl_per_purchase_jobtitle",
"apl_per_custodian_jobtitle",
"apl_per_sales_jobtitle"
];
for (let param of paramsList) {
tableParams = getenumeration(tableParams, param);
}
```
这样可以将代码行数减少一半,并且可以更灵活地修改参数列表。
阅读全文