我试图简化并使一些代码更具可重用性。我有一个功能,需要能够采取一个或多个"设置"参数。
function myFunc(options, value) {
col[options] = value;
//goal is to be able to pass in one or more "sets" of col[options] = value;
}
在这里,我将传递两个"套"参数,我希望它看起来像这样:
function myFunc(options, value) {
col[year] = 3016;
col[type] = fixed;
//passing in two sets for example, but could be 1 or more
}
我觉得我可能会想到这个错误。这可能吗?