当前位置:网站首页>[js] basic syntax - for loop
[js] basic syntax - for loop
2022-07-05 13:49:00 【Weichi Begonia】
Array , Map and Set The cycle of : for of / forEach
The loop of objects : for in
Array of for loop – for (… of … ) / forEach / for (var i=0; i< length ; i++)
var a = [1,2,3,4,5]; for (var each of a){ console.log(each); }
var a = [1,2,3,4,5]; a.forEach(function (element){ console.log(element); })
var a = [1,2,3,4,5]; for (var i=0; i<a.length; i++){ console.log(a[i]); }
Object's for loop – for (… in …) {…}
var obj1 = { 'a':1, 'b':2, 'c':3}; for (var key in obj1){ console.log(key, obj1[key]); }
Map and Set Of for loop – for ( … of …) / forEach()
var m = new Map([['a', 1], ['b',2], ['c', 3]]) for (var element of m){ console.log(element[0], element[1]); }
var m = new Map([['a', 1], ['b',2], ['c', 3]]) m.forEach(function (value, key, map){ console.log(key, value); })
var s = new Set([1,2,3,4,5]); s.forEach(function (element){ console.log(element); })
边栏推荐
- Mmseg - Mutli view time series data inspection and visualization
- 我为什么支持 BAT 拆掉「AI 研究院」
- asp. Net read TXT file
- Kotlin协程利用CoroutineContext实现网络请求失败后重试逻辑
- MMSeg——Mutli-view时序数据检查与可视化
- Datapipeline was selected into the 2022 digital intelligence atlas and database development report of China Academy of communications and communications
- stm32逆向入门
- Idea remote debugging agent
- Those things I didn't know until I took the postgraduate entrance examination
- Data Lake (VII): Iceberg concept and review what is a data Lake
猜你喜欢
zabbix 监控
STM32 reverse entry
Wonderful express | Tencent cloud database June issue
What is a network port
French scholars: the explicability of counter attack under optimal transmission theory
[notes of in-depth study paper]transbtsv2: wider instead of deep transformer for medical image segmentation
Internal JSON-RPC error. {"code":-32000, "message": "execution reverted"} solve the error
【公开课预告】:视频质量评价基础与实践
Win10——轻量级小工具
真正的缓存之王,Google Guava 只是弟弟
随机推荐
Resttemplate details
Integer = = the comparison will unpack automatically. This variable cannot be assigned empty
ETCD数据库源码分析——rawnode简单封装
53. Maximum subarray sum: give you an integer array num, please find a continuous subarray with the maximum sum (the subarray contains at least one element) and return its maximum sum.
Datapipeline was selected into the 2022 digital intelligence atlas and database development report of China Academy of communications and communications
搭建一个仪式感点满的网站,并内网穿透发布到公网 2/2
Apicloud studio3 WiFi real machine synchronization and WiFi real machine preview instructions
Kotlin collaboration uses coroutinecontext to implement the retry logic after a network request fails
Laravel generate entity
Binder communication process and servicemanager creation process
MMSeg——Mutli-view时序数据检查与可视化
Multi person cooperation project to see how many lines of code each person has written
面试官灵魂拷问:为什么代码规范要求 SQL 语句不要过多的 join?
Operational research 68 | the latest impact factors in 2022 were officially released. Changes in journals in the field of rapid care
Solve the problem of "unable to open source file" xx.h "in the custom header file on vs from the source
uplad_ Labs first three levels
Convolutional Neural Networks简述
Elfk deployment
ETCD数据库源码分析——集群间网络层客户端peerRt
Solve the problem of invalid uni app configuration page and tabbar