Js不使用循環生成長度爲10內容分別爲0-9的數組的方法?六種

1、使用Array.apply let arr= Array.apply(null, { length: 10 }).map((item,index)=>{ return index; }); console.log(arr); //(10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 複製代碼 原理:Array.apply的第二個參數是類數組調用Array.a
相關文章
相關標籤/搜索