js不像C语言那样,定义几个参数就一定要几个参数,事实上,传递给函数的参数都保存在arguments"数组"里. 可以对其循环拿到所有传进来的参数
function test(){
for(var i=0;i<arguments.length;i++)
alert(arguments[i]);
}test(1,2,3,4,5,6,7,"chinaren",{id:10},[1,2],new Date());通过这个例子就可以看得清楚些.
function test(){
for(var i=0;i<arguments.length;i++)
alert(arguments[i]);
}test(1,2,3,4,5,6,7,"chinaren",{id:10},[1,2],new Date());通过这个例子就可以看得清楚些.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货