当前位置:网站首页>[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); })
边栏推荐
- asp.net 读取txt文件
- 通讯录(链表实现)
- Attack and defense world web WP
- Matlab paper chart standard format output (dry goods)
- Record in-depth learning - some bug handling
- About the problem and solution of 403 error in wampserver
- Simple PHP paging implementation
- 53. 最大子数组和:给你一个整数数组 nums ,请你找出一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。
- Require, require in PHP_ once、include、include_ Detailed explanation of the efficiency of repeated introduction of once class library
- Redis6 master-slave replication and clustering
猜你喜欢
Could not set property 'ID' of 'class xx' with value 'XX' argument type mismatch solution
Liar report query collection network PHP source code
ELFK部署
Solve the problem of invalid uni app configuration page and tabbar
When using Tencent cloud for the first time, you can only use webshell connection instead of SSH connection.
Win10 - lightweight gadget
The development of speech recognition app with uni app is simple and fast.
French scholars: the explicability of counter attack under optimal transmission theory
How to deal with the Yellow Icon during the installation of wampserver
记录一下在深度学习-一些bug处理
随机推荐
What is a network port
FPGA learning notes: vivado 2019.1 add IP MicroBlaze
真正的缓存之王,Google Guava 只是弟弟
Rk3566 add LED
通讯录(链表实现)
【公开课预告】:视频质量评价基础与实践
Idea set method annotation and class annotation
TortoiseSVN使用情形、安装与使用
龙芯派2代烧写PMON和重装系统
Programmer growth Chapter 8: do a good job of testing
asp.net 读取txt文件
[notes of in-depth study paper]transbtsv2: wider instead of deep transformer for medical image segmentation
Could not set property ‘id‘ of ‘class XX‘ with value ‘XX‘ argument type mismatch 解决办法
49. Grouping of alphabetic ectopic words: give you a string array, please combine the alphabetic ectopic words together. You can return a list of results in any order. An alphabetic ectopic word is a
Godson 2nd generation burn PMON and reload system
Log4j utilization correlation
Liar report query collection network PHP source code
The real king of caching, Google guava is just a brother
49. 字母异位词分组:给你一个字符串数组,请你将 字母异位词 组合在一起。可以按任意顺序返回结果列表。 字母异位词 是由重新排列源单词的字母得到的一个新单词,所有源单词中的字母通常恰好只用一次。
Catch all asynchronous artifact completable future