JavaScript函数中arguments对象
先看代码 functionsayHello(){ if(arguments[0]=="bye") return; alert(arguments[0]); } 1.调用sayHello(‘bye’),直接返回,无任何信息 2.调用sayHello(‘HelloWorld’),提示”HelloWorld” Arguments还提供了一个属性
先看代码
- functionsayHello(){
- if(arguments[0]=="bye")
- return;
- alert(arguments[0]);
- }
1.调用sayHello(‘bye’),直接返回,无任何信息
2.调用sayHello(‘HelloWorld’),提示”HelloWorld”
Arguments还提供了一个属性arguments.length,作用于参数个数:
- funcionargs(){
- alert(arguments.length);
- }
- args(‘a’,1)//提示2
- args()//提示0
- args(23)//提示1
精彩图集
精彩文章






