当前位置:网站首页>Array The from method creates an undefined array of length n
Array The from method creates an undefined array of length n
2022-06-23 05:21:00 【Your beloved brother Qiang】
// Create a 12 individual undefined Array of components
Array.from({length:12})
Equivalent to
[...Array(12)]Some extensions use
Array.from({length:12}).forEach((v,i,ar) => {
console.log(v,i)
});
Usually we can quickly create an array of natural numbers , for example
Array.from({length:12}).forEach((v,i,ar) => {
console.log(i+1+' month ');
//console.log(' The first '+(i+1)+' quarter ');
//console.log(' The first '+(i+1)+' school year ');
});


Quickly create the alphabet 、 Natural number array
[...Array(10)].map((v,i) => 0)//0, 0, 0, 0, 0, 0, 0, 0, 0, 0
[...Array(10)].map((v,i) => i)//0, 1, 2, 3, 4, 5, 6, 7, 8, 9
[...Array(26)].map((v,i) => String.fromCharCode(i + 65))// Output alphabet 
边栏推荐
猜你喜欢

gis利器之Gdal(三)gdb数据读取

Rtklib new version 2.4.3 B34 test comparison

【Laravel系列7.8】广播系统

PRCS-1016 : Failed to resolve Single Client Access Name

MVC three-tier architecture

Visual display of TEQC quality analysis results using teqcplot

软件项目管理 8.4.软件项目质量计划

insert into... Where not exists insert to avoid repeated use

Calculate Euclidean distance and cosine similarity

What is the average annual salary of an outsourced tester who has worked for 5-8 years?
随机推荐
STP summary
关于信息泄露和防御
如何进行探索性数据分析
A bug in rtklib2.4.3 B34 single point positioning
STM32cube 串口使用DMA+IDLE接收不定长数据
Strong push, quick start to software testing
JDBC入门学习(三)之事务回滚功能的实现
Mysql入门学习(一)之语法
[microservices | Nacos] list of issues related to the Nacos version
渗透测试基础 | 附带测试点、测试场景
Zygote process
MCS:连续随机变量——Chi-Square分布
Hcip reissue experiment
架构师之路,从「存储选型」起步
104. 简易聊天室7:使用 Socket 传递对象
Mmdeploy quick installation and instructions
Drag and drop拖放框架
小时候 觉得爸爸就是天 无所不能~
Investment risk management
Mysql入门学习(二)之子查询+关联