js函數傳參,不論傳多少參數,最終都是通過arguments對象來訪問這個數組,從而獲得每個參數。
function sayHi(){
console.log("hello,"+arguments[0]+","+arguments[1]);
}
function howManyArgs(){
console.log(arguments.length);
}
howManyArgs("string",45); //2
howManyArgs(); //0
howManyArgs(12); //1