石川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)
}

 

最新文章

  1. C#学习笔记-封装
  2. C++11 之 override
  3. 实操UNITY3D接入91SDK安卓版
  4. Only top uni produces good ppt.
  5. 类加载器子系统——JVM之四
  6. [week2]每周总结与工作计划
  7. Codeforces 196 C. Paint Tree
  8. WordPress安装到zen-cart产品页中
  9. Python+Selenium定位不到元素常见原因及解决办法(报:NoSuchElementException)
  10. JavaScript数据结构与算法(八) 集合(ECMAScript 6中定义的类似的Set类)
  11. 安装redis,搭建环境
  12. spark伪分布式的安装
  13. 论文笔记:Decoders Matter for Semantic Segmentation: Data-Dependent Decoding Enables Flexible Feature Aggregation
  14. UE4源码笔记
  15. Delphi编码规范
  16. 02:httpd-2.2基础配置
  17. 【基础知识】【1】CDN
  18. 进程优先和ACL
  19. .NET工作准备--02基础知识
  20. ionic4 ios调试打包

热门文章

  1. CentOS 7.6 64位安装docker并设置开机启动
  2. 2.Struts2-Action
  3. Java学习笔记【七、时间、日期、数字】
  4. kubernetes之service
  5. 【转】vm ubuntu14.04 建立共享文件夹
  6. deep_learning_Function_sklearn的train_test_split()
  7. Pyspark常用API总结
  8. (七)zabbix监控nginx
  9. iptables防火墙入门
  10. 设计一个Mypoint类,求两个点之间的距离