0
点赞
收藏
分享

微信扫一扫

Array.from创建指定长度的数组,map生成新内容的数组

Just_Esme 2022-07-01 阅读 67
const arr = Array.from({ length: 10 });
console.log(arr); //[undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined]
const arr2 = arr.map((item) => 1);
console.log(arr2); //[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]


举报

相关推荐

0 条评论