当前位置:网站首页>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))
边栏推荐
猜你喜欢
随机推荐
关于服务治理
ALV报表总结2022.8.9
Snap: 322. Change of Change
《GB5084-2021》PDF下载
tiup cluster upgrade
tiup cluster template
【集训DAY5】快速排序【模拟】【数学】
70. 爬楼梯进阶版
Click: 518. Change Exchange II
金仓数据库 KingbaseGIS 使用手册(6.6. 几何对象校验函数、6.7. 空间参考系函数)
力扣:279.完全平方数
Gartner's global integrated system market data tracking, hyperconverged market growth rate is the first
[Interface Test] Decoding the request body string of the requests library
杭电多校-Counting Stickmen-(思维+组合数+容斥)
Filament-Material 绘制基本图形
【诗歌】被讨厌的勇气
【JZOF】82二叉树中和为某一值的路径(一)
Force Buckle: 474. Ones and zeros
经济衰退即将来临前CIO控制成本的七种方法
《动手学深度学习》(八) -- 多尺度标检测和单发多框检测