1 function createFunction(param1:String,param2:String,param3:int=0):void 2 { 3 trace(arguments.length);//arguments.length表示实参个数 4 } 5 trace(arguments.length);//输出0,说明arguments.length只在函数体内有效 6 trace(createFunction.length);//输出3,说明createFunction.length为定义时的参数个数,不作为传递时的参数个数 7 createFunction("参数1","参数2");//输出2 8 createFunction("参数1","参数2",5);//输出3 9 function createFunction2(...arg):void 10 { 11 //trace(arguments.length);//已经有数组arg,此时arguments不可用,报错 12 trace(arg.length);//arg.length表示实参个数 13 } 14 trace(createFunction2.length);//输出0,说明未定义参数, 15 createFunction2(1,2,3); 16 createFunction2(1,2,3,4);