当前位置:网站首页>[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); })
边栏推荐
- Basic characteristics and isolation level of transactions
- Source code analysis of etcd database -- peer RT of inter cluster network layer client
- Record in-depth learning - some bug handling
- Aspx simple user login
- Jetpack compose introduction to mastery
- Win10 - lightweight gadget
- Laravel framework operation error: no application encryption key has been specified
- 【MySQL 使用秘籍】一網打盡 MySQL 時間和日期類型與相關操作函數(三)
- kafaka 日志收集
- Liar report query collection network PHP source code
猜你喜欢
These 18 websites can make your page background cool
ZABBIX monitoring
[cloud resources] what software is good for cloud resource security management? Why?
When using Tencent cloud for the first time, you can only use webshell connection instead of SSH connection.
Network security - Novice introduction
Flutter 3.0更新后如何应用到小程序开发中
Internal JSON-RPC error. {"code":-32000, "message": "execution reverted"} solve the error
Operational research 68 | the latest impact factors in 2022 were officially released. Changes in journals in the field of rapid care
Intranet penetration tool NetApp
Attack and defense world web WP
随机推荐
uplad_ Labs first three levels
Rk3566 add LED
restTemplate详解
Integer ==比较会自动拆箱 该变量不能赋值为空
Catch all asynchronous artifact completable future
Binder communication process and servicemanager creation process
多人合作项目查看每个人写了多少行代码
南理工在线交流群
::ffff:192.168.31.101 是一个什么地址?
Record in-depth learning - some bug handling
面试官灵魂拷问:为什么代码规范要求 SQL 语句不要过多的 join?
Wechat app payment callback processing method PHP logging method, notes. 2020/5/26
Multi person cooperation project to see how many lines of code each person has written
PostgreSQL Usage Summary (PIT)
Embedded software architecture design - message interaction
[South China University of technology] information sharing of postgraduate entrance examination and re examination
Redis6 master-slave replication and clustering
Zhubo Huangyu: these spot gold investment skills are not really bad
Data Lake (VII): Iceberg concept and review what is a data Lake
leetcode 10. Regular Expression Matching 正则表达式匹配 (困难)