当前位置:网站首页>ES6 从入门到精通 # 13:数组的扩展方法二
ES6 从入门到精通 # 13:数组的扩展方法二
2022-08-09 22:42:00 【凯小默】
说明
ES6 从入门到精通系列(全23讲)学习笔记。
遍历器
entries(),keys(),values(),
返回一个遍历器,可以使用 for···of
循环进行遍历
keys()
:对值遍历values()
:对键值对遍历entries()
:对键名遍历
console.log(["k", "a", "i", "m", "o"].keys());
console.log(["k", "a", "i", "m", "o"].values());
console.log(["k", "a", "i", "m", "o"].entries());
for (let key of ["k", "a", "i", "m", "o"].keys()) {
console.log(key);
}
for (let value of ["k", "a", "i", "m", "o"].values()) {
console.log(value);
}
for (let [key, value] of ["k", "a", "i", "m", "o"].entries()) {
console.log(key, value);
}
let kaimo = ["k", "a", "i", "m", "o"].entries();
console.log(kaimo.next().value)
console.log(kaimo.next().value)
console.log(kaimo.next().value)
console.log(kaimo.next().value)
console.log(kaimo.next().value)
console.log(kaimo.next().value)
includes
includes() 返回一个布尔值,表示某个数组是否包含给定的值
console.log([1,2,3].indexOf(1) > -1)
console.log([1,2,3].includes(1))
边栏推荐
- 【哲理】读书的意义
- 力扣:377. 组合总和 Ⅳ
- JS--popstate事件--使用/教程/实例
- 首席信息官如何将可持续性和技术结合起来
- 如何正则匹配乱码?
- Mysql集群 ShardingSphere
- k8s部署mysql
- A Shanghai technology company was fined 220,000 for brushing orders, exposing the gray industry chain of online brushing
- leetcode 20. Valid Parentheses 有效的括号(中等)
- 什么是平面文件数据库? 如何导入多种格式的文件:DSV、JSON、XML?
猜你喜欢
Live Preview | ICML 2022 11 first-author scholars share online neural network, graph learning and other cutting-edge research
安踏携手华为运动健康共同验证冠军跑鞋 创新引领中国体育
【接口测试】requests 库请求体字符串解码
三:OpenCV图片颜色通道数据转换
Gumbel distribution of discrete choice model
32 JZOF 】 【 print down on binary tree
A summary of 6 common tools for cross-border e-commerce
带着昇腾去旅行:一日看尽金陵城里的AI胜景
高手这样看现货白银走势图
Mysql集群 ShardingSphere
随机推荐
为什么刀具数据库无法打开?
2020年度SaaS TOP100企业名单
【JZOF】32从上往下打印二叉树
Leetcode 235. 二叉搜索树的最近公共祖先
微信小程序获取微信用户步数
ElasticSearcch集群
力扣:377. 组合总和 Ⅳ
直播app开发搭建,flutter 实现自适应、自动换行、相对布局
Technology feast!Huayun Data brings six topics to OpenInfra Days China
HStreamDB v0.9 发布:分区模型扩展,支持与外部系统集成
【哲理】读书的意义
2022-08-09 mysql/stonedb-慢SQL-Q16分析
中国SaaS企业排名,龙头企业Top10梳理
【AtomicInteger】常规用法
你的手机曾经被监控过吗?
直播平台怎么搭建,原生js实现编辑器撤消/恢复功能
H5实现分享功能
外包的水有多深?腾讯15k的外包测试岗能去吗?
LeetCode952三部曲之三:再次优化(122ms -> 96ms,超51% -> 超91%)
【励志】名言警句