石川es6课程---17、ES7 预览
石川es6课程---17、ES7 预览
一、总结
一句话总结:
人的价值恒定规律:无论得意还是迷茫之时,你的价值都不靠外界的评判或者你内心的悲喜而决定。而是当时的恒定的。能够提升他只能靠你提升自己的能力和实力。
1、ES7 预览:数组?
~ arr.includes() 数组是否包含某个东西
~ 数组的 arr.keys(), arr,entries()
~ for ... in 遍历数组 下标 key
~ for ... of 遍历数组 值 value, 不能用于json
let arr = ['a', 'b', 'c']
console.log(arr.includes(1)) for (let i in arr) {
console.log(i) // 循环的时下标 key
} for (let i of arr) {
console.log(i) // 循环的是值 value
}
for (let i of arr.keys()) {
console.log('>'+i)
}
for (let [key, value] of arr.entries()) {
console.log('>' + key + value)
} let json = { a: 12, b: 5, c: 7 }
for (let i in json) {
console.log(i)
}
2、ES7 预览:字符串?
padStart()/padEnd() 指定宽度,不够就补空格或指定字符
console.log('=' + 'abcd'.padStart(6, '0') + '=')
console.log('=' + 'abcd'.padEnd(6, '0') + '=')
=00abcd=
=abcd00=
3、ES7 预览:容忍度?
[1, 2, 3,] 老版数组最后不能有逗号,新的可以有,函数参数最后多的逗号也可以
4、ES7 预览:async await?
和 generator yield 类似,generator 不可以写成箭头函数, async 可以
async function show() {
console.log(1)
await
console.log(2)
}
二、ES7 预览
数组
~ arr.includes() 数组是否包含某个东西
~ 数组的 arr.keys(), arr,entries()
~ for ... in 遍历数组 下标 key
~ for ... of 遍历数组 值 value, 不能用于json
let arr = ['a', 'b', 'c']
console.log(arr.includes(1))
for (let i in arr) {
console.log(i) // 循环的时下标 key
}
for (let i of arr) {
console.log(i) // 循环的是值 value
}
for (let i of arr.keys()) {
console.log('>'+i)
}
for (let [key, value] of arr.entries()) {
console.log('>' + key + value)
}
let json = { a: 12, b: 5, c: 7 }
for (let i in json) {
console.log(i)
}
字符串
padStart()/padEnd() 指定宽度,不够就补空格或指定字符
console.log('=' + 'abcd'.padStart(6, '0') + '=')
console.log('=' + 'abcd'.padEnd(6, '0') + '=')
=00abcd=
=abcd00=
容忍度
[1, 2, 3,] 老版数组最后不能有逗号,新的可以有
函数参数最后多的逗号也可以
async await
和 generator yield 类似
generator 不可以写成箭头函数, async 可以
async function show() {
console.log(1)
await
console.log(2)
}
最新文章
- C#学习笔记-封装
- C++11 之 override
- 实操UNITY3D接入91SDK安卓版
- Only top uni produces good ppt.
- 类加载器子系统——JVM之四
- [week2]每周总结与工作计划
- Codeforces 196 C. Paint Tree
- WordPress安装到zen-cart产品页中
- Python+Selenium定位不到元素常见原因及解决办法(报:NoSuchElementException)
- JavaScript数据结构与算法(八) 集合(ECMAScript 6中定义的类似的Set类)
- 安装redis,搭建环境
- spark伪分布式的安装
- 论文笔记:Decoders Matter for Semantic Segmentation: Data-Dependent Decoding Enables Flexible Feature Aggregation
- UE4源码笔记
- Delphi编码规范
- 02:httpd-2.2基础配置
- 【基础知识】【1】CDN
- 进程优先和ACL
- .NET工作准备--02基础知识
- ionic4 ios调试打包