当前位置:网站首页>js使用for in和for of来简化普通for循环
js使用for in和for of来简化普通for循环
2022-07-27 14:23:00 【讲礼貌】
let arr = [10, 20, 30, 40];
//普通写法
for (let i = 0; i < arr.length; i++) {
console.log(arr[i]);
}
// 简写
for (const val of arr) {
console.log(val);
}
for (const index in arr) {
console.log(arr[index]);
}
边栏推荐
- Leetcode 191. number of 1 bits bit operation /easy
- STM32 can -- can ID filter analysis
- After configuring corswebfilter in grain mall, an error is reported: resource sharing error:multiplealloworiginvalues
- Network equipment hard core technology insider router Chapter 10 Cisco asr9900 disassembly (III)
- Simple mathematical knowledge related to 3D
- Singles cup, web:web check in
- Network equipment hard core technology insider router Chapter 7 tompkinson roaming the network world (Part 2)
- Lua study notes
- Leetcode 341. flattened nested list iterator DFS, stack / medium
- 《剑指Offer》数组中的逆序对
猜你喜欢

The mobile terminal uses the list component of vantui. When multiple tab items are switched back and forth, the list is loaded many times, resulting in the failure of normal display of data

Dialog manager Chapter 3: create controls

After configuring corswebfilter in grain mall, an error is reported: resource sharing error:multiplealloworiginvalues

Basic usage of kotlin

Leetcode 783. binary search tree node minimum distance tree /easy
MOS管防止电源反接的原理

CAN总线的EMC设计方案

Leetcode-1737- minimum number of characters to change if one of the three conditions is met

JMeter recording interface automation

Kubernetes CNI classification / operation mechanism
随机推荐
Tools - common methods of markdown editor
npm install错误 unable to access
西瓜书《机器学习》阅读笔记之第一章绪论
Kubernetes CNI classification / operation mechanism
Principle of MOS tube to prevent reverse connection of power supply
仪表放大器和运算放大器优缺点对比
谷粒商城配置CorsWebFilter后,报错:Resource sharing error:MultipleAllowOriginValues
lua学习笔记
Sword finger offer merges two sorted linked lists
基于stm32的数字示波器设计方案
Network equipment hard core technology insider router Chapter 3 Jia Baoyu sleepwalking in Taixu Fantasy (middle)
Unity mouse controls the first person camera perspective
Unity's simplest object pool implementation
Network equipment hard core technology insider router Chapter 4 Jia Baoyu sleepwalking in Taixu Fantasy (Part 2)
Spark动态资源分配的资源释放过程及BlockManager清理过程
Unity performance optimization ----- occlusion culling of rendering optimization (GPU)
Cap theory and base theory
How to edit a framework resource file separately
Leetcode interview question 17.21. water volume double pointer of histogram, monotonic stack /hard
What is the breakthrough point of digital transformation in the electronic manufacturing industry? Lean manufacturing is the key