在Google脚本自定义函数中接受任意数量的参数? [英] Accept Arbitrary Number of Arguments in Google Scripts Custom Function?
本文介绍了在Google脚本自定义函数中接受任意数量的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图重新构建COUNTIFS作为Google脚本自定义函数,并遇到了一件事:我如何构建一个接受任意数量参数的函数?
I'm trying to re-build COUNTIFS as a Google Scripts Custom Function and having trouble with one thing: how do I build a function that accepts an arbitrary number of arguments?
如果您在Google表单中使用COUNTIFS,则输入如下所示:
If you use COUNTIFS in google sheets, the inputs look like this:
=COUNTIFS(criteria_range1, criterion1, [criteria_range2, criterion2, ...])
我的Google脚本可以是这样的:
My Google Script can be this:
function COUNTIFS(criteria_range1, criterion1){
// CountIFS code
}
...但我如何在我的函数中获得可选参数?
...but how do I get the optional arguments in my function?
推荐答案
您可以参考参数对象时,传递给函数的参数数量是可变的。
You can reference the arguments object when the number of arguments passed to a function is variable.
这篇关于在Google脚本自定义函数中接受任意数量的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文