这篇文章根据 TC39 - proposals - finished-proposals 中 2018 年发布的特性来进行编写。

image.png

Rest/Spread Properties

在 ES2015 中,引入了 ... 运算符,该运算符是对数组进行操作的。而到了 ES2018, ... 运算符可以对对象进行类似的操作。

  1. // rest properties
  2. let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };
  3. x; // 1
  4. y; // 2
  5. z; // { a: 3, b: 4 }
  6. // spread properties
  7. let n = { x, y, ...z };
  8. n; // { x: 1, y: 2, a: 3, b: 4 }

推荐阅读

Promise.prototype.finally

finally() 方法用于指定不管 Promise 对象最后状态如何,都会执行的操作。类似于 try...catch 语句的 finally 语句。

Asynchronous Iterators

这部分涉及的内容较多,因此我列出相关的资料。Iterators 是比较核心的概念,它为所有的数据结构提供了一种统一的的访问机制,它主要是目的是供 for...of 使用。而有了 Iterators 的前置知识,再去了解异步 Iterators 就会简单很多。

前置知识:

asynchronous iterators:

参考资料