用arguments对象检测传递给函数的参数个数:arguments.length
function test(){
if(arguments.length == 1)
alert(arguments[0] + ",你好");
else if(arguments.length == 2)
alert(arguments[0] + "," + arguments[1] + ",你们好")
else
alert("大家好");
}
test(); //输出: 大家好
test("a"); //输出: a,你好
test("a","b"); //输出: a,b,你们好
test("a","b","c","d"); //输出: 大家好