是否可以向JavaScript函数发送可变数量的参数?
var arr = ['a','b','c']var func = function(){ // debug alert(arguments.length); // for(arg in arguments) alert(arg);}func('a','b','c','d'); // prints 4 which is what I want, then 'a','b','c','d'func(arr); // prints 1, then 'Array'
def func(*args): print len(args) for i in args: print i func('a','b','c','d'); // prints 4 which is what I want, then 'a','b','c','d'func(*arr) // prints 4 which is what I want, then 'a','b','c','d'
qq_遁去的一_1
largeQ
相关分类