array
1. Array(9).fill(null)
创建长度为 9
的数组,并且用 null
填充。
2. Array.from({length:3},(_,idx) => {return idx*3;})
方法定义:Array.from
Array.from(
// 带有 length 的类数组对象
{
0:1,
1:2,
2:3,
length: 3
},
// 回调函数 ele: 元素,idx: 索引
(ele, idx) => {
console.log(aa, idx);
return idx;
}
);