arguments 表明的是實參 , 有一個講究的地方是 : arguments 只在函數中使用 數組
例子:函數
fn(2,4); fn(2,4,6); fn(2,4,6,8); function fn(a,b,c) { console.log(arguments); console.log(fn.length); //獲取形參的個數 console.log(arguments.length); //獲取實參的個數 console.log("----------------"); }
例如 : spa
fn(2,4); fn(2,4,6); fn(2,4,6,8); function fn(a,b) { arguments[0] = 99; //將實參的第一個數改成99 arguments.push(8); //此方法不經過,由於沒法增長元素 }
清空數組的幾種方式:code
array.splice(0); 刪除數組中全部項目 blog
array.length = 0 ; length屬性能夠賦值 , 在其餘語言中length是隻讀 io
array = [ ] ; 推薦使用該種方法console
var array = [1,2,3,4,5,6]; array.splice(0); //方式1:刪除數組中全部項目 array.length = 0; //方式1:length屬性能夠賦值,在其它語言中length是隻讀 array = []; //方式3:推薦