当前位置:网站首页>[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); })
边栏推荐
- When using Tencent cloud for the first time, you can only use webshell connection instead of SSH connection.
- Convolutional Neural Networks简述
- Jetpack Compose入门到精通
- 2022年机修钳工(高级)考试题模拟考试题库模拟考试平台操作
- About the problem and solution of 403 error in wampserver
- MySQL get time
- Assembly language - Beginner's introduction
- web3.eth. Filter related
- laravel-dompdf导出pdf,中文乱码问题解决
- Parsing XML using Dom4j
猜你喜欢
ELFK部署
Zibll theme external chain redirection go page beautification tutorial
记录一下在深度学习-一些bug处理
Primary code audit [no dolls (modification)] assessment
Can graduate students not learn English? As long as the score of postgraduate entrance examination English or CET-6 is high!
Solve the problem of invalid uni app configuration page and tabbar
[public class preview]: basis and practice of video quality evaluation
STM32 reverse entry
When using Tencent cloud for the first time, you can only use webshell connection instead of SSH connection.
French scholars: the explicability of counter attack under optimal transmission theory
随机推荐
2022建筑焊工(建筑特殊工种)特种作业证考试题库及在线模拟考试
mysql获得时间
Jetpack compose introduction to mastery
ELFK部署
南理工在线交流群
asp. Net read TXT file
通讯录(链表实现)
私有地址有那些
Internal JSON-RPC error. {"code":-32000, "message": "execution reverted"} solve the error
真正的缓存之王,Google Guava 只是弟弟
ETCD数据库源码分析——集群间网络层客户端peerRt
这18个网站能让你的页面背景炫酷起来
ETCD数据库源码分析——rawnode简单封装
Resttemplate details
Hide Chinese name
The development of speech recognition app with uni app is simple and fast.
那些考研后才知道的事
What happened to the communication industry in the first half of this year?
ZABBIX monitoring
Interviewer soul torture: why does the code specification require SQL statements not to have too many joins?