2022
class相关
class X {#a; // 私有变量#b=1get b() { //get、setreturn this.#b;}static getBofX(x) {if(#b in x) return x.#belse return 'fail'}static { //静态块console.log('hello')}}try {}catch(e) {console.log(e);}
top-level await
// users.jsexport const users = await fetch('/users/lists');// usage.jsimport { users } from "./users.js";// ✅ the module will wait for users to be fullfilled prior to executing any codeconsole.log(users);
在web开发中,当同时使用事件监听和top-level await,会导致代码的执行顺序不确定。
Error cause
async function f(url) {try {let x = await fetch(url);} catch(e) {throw new Error("fail", {cause: e})}}try {await f("x:x");} catch (e) {console.log(e, e.cause);}
参考
【1】https://www.ecma-international.org/
【2】https://yanhaijing.com/es5/#about
