//1.argument.length;用arguments下标遍访参数
function testArgument(){
if (arguments.length == 0) {
document.write("未传入参数")
}
else {
document.write("传入参数为:"+"
");
for (var i = 0; i < arguments.length; i++) {
document.write(arguments[i] + "
");
}
}
}
testArgument("Hello","Welcome","你好","欢迎","here","光临");
//2.arguments的类型
function testType(){
document.write("arguments的类型:"+typeof(arguments)+"
");
}
testType();
//3.arguments.callee对自身函数的调用
function testSum(n){
var result;
if(n==1){
result=1;
}else{
result=n+ arguments.callee(n-1);
}
return result;
}
function testAdd(){
var n=100;
document.write("1+2+3+.....+n="+testSum(n));
}
testAdd();
阅读(1003) | 评论(0) | 转发(0) |