当前位置:网站首页>Array object methods commonly used traversal methods & higher-order functions
Array object methods commonly used traversal methods & higher-order functions
2022-07-24 18:11:00 【Solution without encirclement】
3、 ... and 、 Common traversal methods & Higher order function
1.for()
Most commonly used for loop , Frequently used array traversal , You can also traverse strings .
const arr = [1, 2, 3]
const str = 'abc'
for (let i = 0; i < arr.length; i++) {
console.log(arr[i])
console.log(str[i])
}
2.while() / do while()
while、do while The main functions are , When satisfied while The following conditions , To perform related business . The difference between the two is ,while Will first judge whether the conditions are met , Then perform the tasks in curly braces , and do while It is to perform the task in curly brackets first , To perform while Conditions , Judge whether to execute again next time do Operation inside . in other words do while At least one operation will be performed .
while( Conditions ){
perform ...
}
------------
do{
perform ...
}
while( Conditions )
3.forEach()
Copy a copy to traverse the original array .
returnCannot terminate loop . But it can playcontinueeffect .It doesn't support itself
continueAndbreakWe can usesomeandeveryTo achieve .
边栏推荐
猜你喜欢

C language custom type explanation - Consortium

0630~职业素养课

继承与派生

Bib | mol2context vec: context aware deep network model learning molecular representation for drug discovery

SSM framework learning

Inheritance and Derive

Laravel notes - RSA encryption of user login password (improve system security)

【obs】依赖库: x264 vs 构建

How does win11 enhance the microphone? Win11 enhanced microphone settings

Win10 super good-looking mouse theme, you also try it
随机推荐
0621~ES&Lucene
0612~quartz timer frame
Baidu touch.js
How to prepare for hyperinflation
Stream, file, IO
0621~ES&Lucene
Single cell code analysis - gynecological cancer single cell transcriptome and chromatin accessibility analysis 1
阿里巴巴/166获得店铺的所有商品 API使用说明
Inheritance and Derive
File upload vulnerability -.User.ini and.Htaccess
Emerging potential of interactive virtual reality technology in drug discovery
Alibaba /1688 API instructions for searching products by map (pailitao)
Shanghai Jiaotong University team used joint deep learning to optimize metabonomics research
After separation, the impression notes are still difficult to live, but there are many coquettish operations
字符串常用方法(2)
The collapse of margin
[OBS] cooperation between video and audio coding and RTMP transmission
Problems needing attention in writing pages
Icml2022 Best Paper Award: learning protein reverse folding from millions of predicted structures
T245982 「KDOI-01」醉花阴