const array = new Array(9).fill('')
//fill:使用固定值填充數(shù)組
Array.from({length: 5}, (v, i) => i);
// [0, 1, 2, 3, 4]
示例:想要?jiǎng)?chuàng)建一個(gè)指定長(zhǎng)度數(shù)組租副,并填充自己想要的數(shù)據(jù)
let addIconList=(new Array(96).fill('')).map((v,k)=>{
return ('selfIcon icons-a-' + (k+1))
}),
console.log(addIconList)//['selfIcon icons-a-1', 'selfIcon icons-a-2', 'selfIcon icons-a-3'',....]