当前位置:网站首页>for..of vs. for..in 语句
for..of vs. for..in 语句
2022-06-22 15:22:00 【xiao_zhu_ting_feng】
for..of和for..in均可迭代一个列表;但是用于迭代的值却不同,for..in迭代的是对象的 键 的列表,而for..of则迭代对象的键对应的值。
下面的例子展示了两者之间的区别:
let list = [4, 5, 6];
for (let i in list) {
console.log(i); // "0", "1", "2",
}
for (let i of list) {
console.log(i); // "4", "5", "6"
}
边栏推荐
猜你喜欢

音视频基础知识|ANS 噪声抑制原理解析

SAP ABAP sub screen tutorial: call sub screen -010 in SAP

什么是RESTful,REST api设计时应该遵守什么样的规则?

SAP ABAP 中的用户出口和客户出口-015

SAP web service cannot log in to SOA management page with soamanager

什么是 SAP ABAP? 类型、ABAP 完整形式和含义

How to embody the value of knowledge management in business

SAP ABAP 表控制与示例-07

Pod type

SAP ABAP 中的 Smart Forms-014
随机推荐
nio编程service
10款超牛Vim插件,爱不释手了
全球首款AR隐形眼镜,元宇宙入口这次真的打开了?
Lecture 6 of slam Lecture 14 -- nonlinear optimization
SAP ABAP report programming-08
1.类的继承(point)
shell学习
SAP 中的 ABAP 查询教程:SQ01、SQ02、SQ03-017
[Shanda conference] use typescript to reconstruct the project
异步IO的简单理解
短视频源码开发,优质的短视频源码需要做好哪几点?
3. Classe abstraite (forme)
超出文本部分用省略号表示
Swift -- 保存打印日志到沙盒
谷歌浏览器的小细节
预约打新债到底安不安全呀?是不是靠谱的?
SAP价值流程&帮助请求流程-011
The odoo system sets priorities for the views independently developed by the original model
SAP ABAP 中的模块化:宏、子程序和功能模块 -04
SAP value process & help request process-011