【发布时间】:2017-03-19 11:31:20
【问题描述】:
作为对以下问题的跟进,我需要将收到的参数发送到另一个函数。
Pass unknown number of arguments into javascript function
例如:
myObj.RunCall("callName", 1,2,3,4,5);
myObj.RunCall("anotherCall", 1);
myObj.RunCall("lastCall");
在哪里
runCall = function(methodName)
{
// do something clever with methodName here, consider it 'used up'
console.log(methodName);
// using 'arguments' here will give me all the 'extra' args
var x = arguments.length;
// somehow extract all the extra args into local vars?
// assume there were 4 (there could be 0-100)
otherObj.DoIt(arg1, arg2, arg3, arg4); // here i need to send those "extra" args onwards
}
【问题讨论】:
标签: javascript methods