// 方法一 Array.map /*function createData() { // 如果不 fill 循环默认会跳过空值 return new Array(1000).fill(null).map((v, i) => ({ name: `name${i + 1}` })); } const data = createData(); console.log(data); */ // 方法二 Array.from /*function createData() { return Array.from({ length: 1000 }, (v, i) => ({ name: `name${i + 1}` })); } const data = createData(); console.log(data); */