当前位置:网站首页>[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); })
边栏推荐
- Binder communication process and servicemanager creation process
- leetcode 10. Regular Expression Matching 正则表达式匹配 (困难)
- kafaka 日志收集
- 私有地址有那些
- laravel-dompdf导出pdf,中文乱码问题解决
- uplad_ Labs first three levels
- 什么叫做信息安全?包含哪些内容?与网络安全有什么区别?
- Aspx simple user login
- What is a network port
- PHP character capture notes 2020-09-14
猜你喜欢

【云资源】云资源安全管理用什么软件好?为什么?
![Primary code audit [no dolls (modification)] assessment](/img/b8/82c32e95d1b72f75823ca91c97138e.jpg)
Primary code audit [no dolls (modification)] assessment

Rk3566 add LED

Liar report query collection network PHP source code

Solve the problem of invalid uni app configuration page and tabbar

Data Lake (VII): Iceberg concept and review what is a data Lake

STM32 reverse entry

荐号 | 有趣的人都在看什么?

Attack and defense world web WP

Nantong online communication group
随机推荐
Elfk deployment
Jasypt configuration file encryption | quick start | actual combat
Embedded software architecture design - message interaction
53. 最大子数组和:给你一个整数数组 nums ,请你找出一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。
那些考研后才知道的事
PHP generate Poster
With 4 years of working experience, you can't tell five ways of communication between multithreads. Dare you believe it?
多人合作项目查看每个人写了多少行代码
Laravel framework operation error: no application encryption key has been specified
Win10 - lightweight gadget
asp. Net read TXT file
通讯录(链表实现)
Apicloud studio3 WiFi real machine synchronization and WiFi real machine preview instructions
Network security HSRP protocol
PHP character capture notes 2020-09-14
【华南理工大学】考研初试复试资料分享
Could not set property ‘id‘ of ‘class XX‘ with value ‘XX‘ argument type mismatch 解决办法
Catch all asynchronous artifact completable future
Introduction to Chapter 8 proof problem of njupt "Xin'an numeral base"
Idea remote debugging agent