在 Javascript 中的可变参数函数内调用可变参数函数?
我有两个函数 a() 和 b(),都是可变参数函数,假设当我像这样调用函数 a() 时:
a(arg0, arg1, arg2, arg3, ...., argn);
那么函数 b() 也会在 a() 内部被调用,但没有第一个参数a() 的参数列表中的“arg0”:
b(arg1, arg2, arg3, ...., argn);
有什么办法吗?
I have two function a() and b(), both are variadic functions, let say when I call function a() like this :
a(arg0, arg1, arg2, arg3, ...., argn);
then the function b() will be called as well inside a(), but without the first argument "arg0" in the arguments list of a() :
b(arg1, arg2, arg3, ...., argn);
Is there any way for it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每个 JavaScript
function
实际上只是另一个“对象”(JavaScript 意义上的对象),并且带有一个apply
方法(请参阅 Mozilla 文档)。因此你可以做这样的事情......Every JavaScript
function
is really just another "object" (object in the JavaScript sense), and comes with anapply
method (see Mozilla's documentation). You can thus do something like this....