{"componentChunkName":"component---src-templates-blog-post-js","path":"/es6+/","result":{"data":{"site":{"siteMetadata":{"title":"按太阳穴轮刮眼眶"}},"markdownRemark":{"id":"65ea000a-b635-5aad-a0c8-b0e5d6edf37b","excerpt":"ES2021 逻辑赋值运算符 数字分隔符 Promise.any() String.replaceAll() WeakRefs 与 FinalizationRegistry ES 2020 链式判断运算符 ?. ?? 运算符 import() 函数 export * as xx from \"someModule…","html":"<div class=\"table-of-contents\">\n<ul>\n<li>\n<p><a href=\"#es2021\">ES2021</a></p>\n<ul>\n<li><a href=\"#%E9%80%BB%E8%BE%91%E8%B5%8B%E5%80%BC%E8%BF%90%E7%AE%97%E7%AC%A6\">逻辑赋值运算符</a></li>\n<li><a href=\"#%E6%95%B0%E5%AD%97%E5%88%86%E9%9A%94%E7%AC%A6\">数字分隔符</a></li>\n<li><a href=\"#promiseany\">Promise.any()</a></li>\n<li><a href=\"#stringreplaceall\">String.replaceAll()</a></li>\n<li><a href=\"#weakrefs-%E4%B8%8E-finalizationregistry\">WeakRefs 与 FinalizationRegistry</a></li>\n</ul>\n</li>\n<li>\n<p><a href=\"#es-2020\">ES 2020</a></p>\n<ul>\n<li><a href=\"#%E9%93%BE%E5%BC%8F%E5%88%A4%E6%96%AD%E8%BF%90%E7%AE%97%E7%AC%A6-\">链式判断运算符 <code>?.</code></a></li>\n<li><a href=\"#-%E8%BF%90%E7%AE%97%E7%AC%A6\"><code>??</code> 运算符</a></li>\n<li><a href=\"#import-%E5%87%BD%E6%95%B0\"><code>import()</code> 函数</a></li>\n<li><a href=\"#export--as-xx-from-somemodule\"><code>export * as xx from \"someModule\"</code></a></li>\n<li><a href=\"#bigint-%E7%B1%BB%E5%9E%8B\">BigInt 类型</a></li>\n<li><a href=\"#promiseallsettled\">Promise.allSettled()</a></li>\n<li><a href=\"#stringmatchall\">String.matchAll()</a></li>\n<li><a href=\"#globalthis\">globalThis</a></li>\n<li><a href=\"#forin-%E5%AE%9A%E4%B9%89%E4%BA%86%E6%98%8E%E7%A1%AE%E7%9A%84%E9%A1%BA%E5%BA%8F\"><code>for..in</code> 定义了明确的顺序</a></li>\n<li><a href=\"#importmeta\">import.meta</a></li>\n</ul>\n</li>\n<li>\n<p><a href=\"#es-2019\">ES 2019</a></p>\n<ul>\n<li><a href=\"#stringtrimstart--stringtrimend\">String.trimStart() / String.trimEnd()</a></li>\n<li><a href=\"#objectfromentries\">Object.fromEntries()</a></li>\n<li><a href=\"#arrayflat--arrayflatmap\">Array.flat() / Array.flatMap()</a></li>\n<li><a href=\"#catch-%E5%8F%82%E6%95%B0%E5%8F%AF%E7%9C%81%E7%95%A5\">catch 参数可省略</a></li>\n<li><a href=\"#symboldescription\">Symbol.description</a></li>\n<li><a href=\"#%E5%8A%A0%E5%BC%BA-jsonparse-%E4%B8%8E-jsonstringify\">加强 JSON.parse() 与 JSON.stringify()</a></li>\n<li><a href=\"#arraysort%E6%9B%B4%E5%8A%A0%E7%A8%B3%E5%AE%9A\">Array.sort()更加稳定</a></li>\n<li><a href=\"#functiontostring-%E9%87%8D%E6%96%B0%E4%BF%AE%E8%AE%A2\">Function.toString() 重新修订</a></li>\n</ul>\n</li>\n<li>\n<p><a href=\"#es-2018\">ES 2018</a></p>\n<ul>\n<li><a href=\"#for-awaitof\">for await...of</a></li>\n<li><a href=\"#promisefinally\">Promise.finally()</a></li>\n<li><a href=\"#object-rest-properties\">Object Rest Properties</a></li>\n<li><a href=\"#new-regexp-features\">New RegExp Features</a></li>\n</ul>\n</li>\n<li>\n<p><a href=\"#es-2017\">ES 2017</a></p>\n<ul>\n<li><a href=\"#string-padding\">String Padding</a></li>\n<li><a href=\"#objectentries\">Object.entries()</a></li>\n<li><a href=\"#objectvalues\">Object.values()</a></li>\n<li><a href=\"#async-functions\">Async Functions</a></li>\n<li><a href=\"#objectgetownpropertydescriptor\">Object.getOwnPropertyDescriptor()</a></li>\n<li><a href=\"#%E5%87%BD%E6%95%B0%E5%8F%82%E6%95%B0%E5%88%97%E8%A1%A8%E4%B8%AD%E7%9A%84%E5%B0%BE%E9%9A%8F%E9%80%97%E5%8F%B7\">函数参数列表中的尾随逗号</a></li>\n<li><a href=\"#sharedarraybuffer-%E5%92%8C-atomics\">SharedArrayBuffer 和 Atomics</a></li>\n</ul>\n</li>\n<li>\n<p><a href=\"#es-2016\">ES 2016</a></p>\n<ul>\n<li><a href=\"#%E6%B1%82%E5%B9%82%E8%BF%90%E7%AE%97%E7%AC%A6-\">求幂运算符 **</a></li>\n<li><a href=\"#arrayincludes\">Array.includes()</a></li>\n</ul>\n</li>\n<li>\n<p><a href=\"#es6-es2015\">ES6 (ES2015)</a></p>\n<ul>\n<li><a href=\"#%E5%85%B3%E9%94%AE%E5%AD%97%E5%92%8C%E7%B1%BB%E5%9E%8B\">关键字和类型</a></li>\n<li><a href=\"#function\">Function</a></li>\n<li><a href=\"#string\">String</a></li>\n<li><a href=\"#array\">Array</a></li>\n<li><a href=\"#math\">Math</a></li>\n<li><a href=\"#number\">Number</a></li>\n<li><a href=\"#global-methods\">Global Methods</a></li>\n<li><a href=\"#object\">Object</a></li>\n<li><a href=\"#javascript-modules\">JavaScript Modules</a></li>\n</ul>\n</li>\n</ul>\n</div>\n<h2 id=\"es2021\" style=\"position:relative;\"><a href=\"#es2021\" aria-label=\"es2021 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>ES2021</h2>\n<h3 id=\"逻辑赋值运算符\" style=\"position:relative;\"><a href=\"#%E9%80%BB%E8%BE%91%E8%B5%8B%E5%80%BC%E8%BF%90%E7%AE%97%E7%AC%A6\" aria-label=\"逻辑赋值运算符 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>逻辑赋值运算符</h3>\n<p>类似于 <code>+=</code> <code>*=</code> 等运算符:</p>\n<ul>\n<li><code>??=</code></li>\n<li><code>&#x26;&#x26;=</code></li>\n<li><code>||=</code></li>\n</ul>\n<pre><code class=\"language-jsx\">let a = null\na ??= \"flag\" // a = a ?? \"flag\"\na &#x26;&#x26;= \"flag\" // a = a &#x26;&#x26; \"flag\"\na ||= \"falg\" // a = a || \"flag\"\n</code></pre>\n<h3 id=\"数字分隔符\" style=\"position:relative;\"><a href=\"#%E6%95%B0%E5%AD%97%E5%88%86%E9%9A%94%E7%AC%A6\" aria-label=\"数字分隔符 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>数字分隔符</h3>\n<p>允许在数字中间添加下划线 <code>_</code> 增强可读性.</p>\n<p>不允许出现在数字的首尾位置.</p>\n<p>如: <code>1_000_000</code></p>\n<p>注意: 带下划线的 String 类型的数字无法正常转换:</p>\n<pre><code class=\"language-jsx\">Number(1_000) // 1000\nNumber(\"1_000\") // NaN\n</code></pre>\n<h3 id=\"promiseany\" style=\"position:relative;\"><a href=\"#promiseany\" aria-label=\"promiseany permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Promise.any()</h3>\n<p>接收一个 Promise 数组, 返回第一个 <code>fulfilled</code> 的 Promise 返回值.</p>\n<p>当所有的 Promise 都 <code>rejected</code> 时, 进入 <code>catch</code> 块并返回 <code>AggregateError</code> 类型的错误.</p>\n<p>对比 Promise.race() 是返回第一个 <code>fulfilled</code> 或 <code>rejected</code> 的 Promise 返回值.</p>\n<h3 id=\"stringreplaceall\" style=\"position:relative;\"><a href=\"#stringreplaceall\" aria-label=\"stringreplaceall permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>String.replaceAll()</h3>\n<p><code>String.replace()</code> 只替换第一次匹配的字符</p>\n<h3 id=\"weakrefs-与-finalizationregistry\" style=\"position:relative;\"><a href=\"#weakrefs-%E4%B8%8E-finalizationregistry\" aria-label=\"weakrefs 与 finalizationregistry permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>WeakRefs 与 FinalizationRegistry</h3>\n<p>WeakRefs 为对象创建一个弱引用, 弱引用不会组织 JS 引擎垃圾回收期的回收, 一般很少使用.</p>\n<p>使用 FinalizationRegistry 对象可以在垃圾回收器回收对象时, 执行回调函数:</p>\n<pre><code class=\"language-jsx\">// 构建监听对象被垃圾回收器清除的回调\nconst registry = new FinalizationRegistry(heldValue => {\n  console.log(\"----\", heldValue)\n})\n\nconst obj = {}\nconst token = {}\n\n// 注册监听\nregistry.register(obj, \"obj deleted!\", token)\n\n// 取消监听\n// registry.unregister(token);\n\n// 可能很久以后，回调执行\n// ---- obj deleted!\n</code></pre>\n<h2 id=\"es-2020\" style=\"position:relative;\"><a href=\"#es-2020\" aria-label=\"es 2020 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>ES 2020</h2>\n<h3 id=\"链式判断运算符-\" style=\"position:relative;\"><a href=\"#%E9%93%BE%E5%BC%8F%E5%88%A4%E6%96%AD%E8%BF%90%E7%AE%97%E7%AC%A6-\" aria-label=\"链式判断运算符  permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>链式判断运算符 <code>?.</code></h3>\n<p>支持 <code>obj?.a?.b?.c</code> 运算, 当中间某个属性为 <code>null</code> 或 <code>undefined</code> 时, 直接返回 <code>undefined</code> .</p>\n<p>同时支持 <code>obj?.[expr]</code> 方括号形式与 <code>fun?.(...args)</code> 函数调用形式.</p>\n<h3 id=\"-运算符\" style=\"position:relative;\"><a href=\"#-%E8%BF%90%E7%AE%97%E7%AC%A6\" aria-label=\" 运算符 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>??</code> 运算符</h3>\n<p>类似于 <code>||</code> , 但只有运算符左侧值为 <code>null</code> 或 <code>undefined</code> 时才返回右侧值.</p>\n<p>如 <code>const username = list?.info?.base?.username ?? 'user';</code></p>\n<p>而 <code>||</code> 运算符在左侧为 <code>null</code> <code>undefined</code> <code>''</code> <code>false</code> 和 <code>0</code> 时都会返回右侧值.</p>\n<h3 id=\"import-函数\" style=\"position:relative;\"><a href=\"#import-%E5%87%BD%E6%95%B0\" aria-label=\"import 函数 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>import()</code> 函数</h3>\n<p>之前的 <code>import</code> 只能用在模块顶层, 无法支持动态加载或条件导入模块.</p>\n<p><code>import()</code> 函数支持动态加载模块, 返回一个 <code>Promise</code> :</p>\n<pre><code class=\"language-jsx\">if (page === \"home\") {\n  import(\"./home.js\")\n    .then(({ export1, export2 }) => {\n      // 加载成功\n    })\n    .catch(err => {\n      // 加载失败\n    })\n}\n</code></pre>\n<p>适用于:</p>\n<ul>\n<li>按需加载(如点击某按钮)</li>\n<li>条件加载</li>\n<li>动态的模块路径</li>\n</ul>\n<h3 id=\"export--as-xx-from-somemodule\" style=\"position:relative;\"><a href=\"#export--as-xx-from-somemodule\" aria-label=\"export  as xx from somemodule permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>export * as xx from \"someModule\"</code></h3>\n<p>相当于以下两个语句:</p>\n<ul>\n<li><code>import * as xx from \"someModule\";</code></li>\n<li><code>export {xx};</code></li>\n</ul>\n<h3 id=\"bigint-类型\" style=\"position:relative;\"><a href=\"#bigint-%E7%B1%BB%E5%9E%8B\" aria-label=\"bigint 类型 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>BigInt 类型</h3>\n<p>可精确表示任意位数的整数, BigInt 类型的数据需要添加后缀 <code>n</code> .</p>\n<pre><code class=\"language-jsx\">const n = 34242345425325n\ntypeof n // \"bigint\"\n// 作为构造函数\nBigInt(3243) // 3243n\nBigInt(\"324\") // 324n\nBigInt(false) // 0n\nBigInt(true) // 1n\n</code></pre>\n<h3 id=\"promiseallsettled\" style=\"position:relative;\"><a href=\"#promiseallsettled\" aria-label=\"promiseallsettled permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Promise.allSettled()</h3>\n<p>接收一组 Promise 实例作为参数, 当这些 Promise 都返回结果, 无论是 <code>fulfilled</code> 还是 <code>rejected</code> , 状态都会变为 <code>fulfilled</code> , 返回 <code>[{ status: \"fulfilled\" | \"rejected\", value?: any, reason?: any }]</code></p>\n<pre><code class=\"language-jsx\">const resolved = Promise.resolve(42)\nconst rejected = Promise.reject(-1)\n\nconst allSettledPromise = Promise.allSettled([resolved, rejected])\n\nallSettledPromise.then(function (results) {\n  console.log(results)\n})\n// [\n//    { status: 'fulfilled', value: 42 },\n//    { status: 'rejected', reason: -1 }\n// ]\n</code></pre>\n<p><a href=\"https://www.notion.so/0c758a80f21045159ebd28652c288c05\">Promise.allSettled(), Promise.all(), Promise.race()</a></p>\n<h3 id=\"stringmatchall\" style=\"position:relative;\"><a href=\"#stringmatchall\" aria-label=\"stringmatchall permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>String.matchAll()</h3>\n<p>返回一个正则表达式在当前字符串中的所有匹配.</p>\n<p>返回一个迭代器, 可以使用 <code>for..of</code> 遍历或使用 <code>Array.from()</code> 转为数组遍历.</p>\n<pre><code class=\"language-jsx\">let regex = /t(e)(st(\\d?))/g\nlet string = \"test1test2test3\"\nlet r = string.matchAll(regex)\nArray.from(r)\n// [[\"test1\", \"e\", \"str1\", \"1\"],\n//  [\"test2\", \"e\", \"str2\", \"2\"],\n//  [\"test3\", \"e\", \"str3\", \"3\"]]\n</code></pre>\n<h3 id=\"globalthis\" style=\"position:relative;\"><a href=\"#globalthis\" aria-label=\"globalthis permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>globalThis</h3>\n<p>全局属性 <code>globalThis</code> 包含全局的 <code>this</code> 对象.</p>\n<p>以前在不同环境下获取全局 <code>this</code> 对象的方法各不相同, 如:</p>\n<ul>\n<li>在 Web 中通过 <code>window</code> 或 <code>self</code> 获取 <code>this</code></li>\n<li>在 WebWorkers 中只能通过 <code>self</code> 获取 <code>this</code></li>\n<li>在 Nodejs 中需要使用 <code>global</code> 获取 <code>this</code></li>\n</ul>\n<p>需要通过判断各种对象是否存在来获取 <code>this</code>, 较为繁琐.</p>\n<p><code>globalThis</code> 提供了一个标准方式来获取全局 <code>this</code> , 在各种环境下都适用.</p>\n<h3 id=\"forin-定义了明确的顺序\" style=\"position:relative;\"><a href=\"#forin-%E5%AE%9A%E4%B9%89%E4%BA%86%E6%98%8E%E7%A1%AE%E7%9A%84%E9%A1%BA%E5%BA%8F\" aria-label=\"forin 定义了明确的顺序 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>for..in</code> 定义了明确的顺序</h3>\n<p><code>for (x in y)</code> 语句将以规定的顺序执行.</p>\n<h3 id=\"importmeta\" style=\"position:relative;\"><a href=\"#importmeta\" aria-label=\"importmeta permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>import.meta</h3>\n<p>返回带有 <code>url</code> 属性的对象, 可获取模块的基础 URL.</p>\n<pre><code class=\"language-jsx\">;&#x3C;script type=\"module\" src=\"module.js\">&#x3C;/script>\n\nconsole.log(import.meta) // { url: \"file:///home/user/module.js\" }\n</code></pre>\n<h2 id=\"es-2019\" style=\"position:relative;\"><a href=\"#es-2019\" aria-label=\"es 2019 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>ES 2019</h2>\n<h3 id=\"stringtrimstart--stringtrimend\" style=\"position:relative;\"><a href=\"#stringtrimstart--stringtrimend\" aria-label=\"stringtrimstart  stringtrimend permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>String.trimStart() / String.trimEnd()</h3>\n<p>单独去掉 String 头或尾部的空白字符.</p>\n<h3 id=\"objectfromentries\" style=\"position:relative;\"><a href=\"#objectfromentries\" aria-label=\"objectfromentries permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Object.fromEntries()</h3>\n<p>即 <code>Object.entries()</code> 的逆过程, 将 <code>[[key, value]]</code> 形式的键值对转为对象结构:</p>\n<pre><code class=\"language-jsx\">let obj = { a: \"aa\", b: 40 }\nlet entries = Object.entries(obj)\nentries // [[\"a\", \"aa\"], [\"b\", 40]]\nlet obj1 = Object.fromEntries(entries)\nobj1 // {a: \"aa\", b: 40}\n</code></pre>\n<h3 id=\"arrayflat--arrayflatmap\" style=\"position:relative;\"><a href=\"#arrayflat--arrayflatmap\" aria-label=\"arrayflat  arrayflatmap permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Array.flat() / Array.flatMap()</h3>\n<ul>\n<li>\n<p>Array.flat([depth = 1]) 按照指定深度展开/铺平数组, 默认深度为 1</p>\n<pre><code class=\"language-jsx\">const arr1 = [1, 2, [3, 4]]\narr1.flat() // [1,2,3,4]\nconst arr2 = [1, 2, [[[3, 4]]]]\narr2.flat(2) // [1,2,[3,4]]\narr2.flat(3) // [1,2,3,4]\n</code></pre>\n</li>\n<li>\n<p>Array.flatMap() 即 <code>Array.map()</code> + <code>Array.flat(1)</code></p>\n<pre><code class=\"language-jsx\">let arr1 = [\"it's Sunny in\", \"\", \"California\"]\n\narr1.map(x => x.split(\" \"))\n// [[\"it's\",\"Sunny\",\"in\"],[\"\"],[\"California\"]]\n\narr1.flatMap(x => x.split(\" \"))\n// [\"it's\",\"Sunny\",\"in\", \"\", \"California\"]\n</code></pre>\n</li>\n</ul>\n<h3 id=\"catch-参数可省略\" style=\"position:relative;\"><a href=\"#catch-%E5%8F%82%E6%95%B0%E5%8F%AF%E7%9C%81%E7%95%A5\" aria-label=\"catch 参数可省略 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>catch 参数可省略</h3>\n<p>支持语法 <code>try {...} catch {...}</code> .</p>\n<h3 id=\"symboldescription\" style=\"position:relative;\"><a href=\"#symboldescription\" aria-label=\"symboldescription permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Symbol.description</h3>\n<p>获取 Symbol 对象创建时的描述信息:</p>\n<pre><code class=\"language-jsx\">const symbol = Symbol(\"This is a symbol\")\nsymbol // Symbol(This is a symbol)\nsymbol.description // \"This is a symbol\"\n</code></pre>\n<h3 id=\"加强-jsonparse-与-jsonstringify\" style=\"position:relative;\"><a href=\"#%E5%8A%A0%E5%BC%BA-jsonparse-%E4%B8%8E-jsonstringify\" aria-label=\"加强 jsonparse 与 jsonstringify permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>加强 JSON.parse() 与 JSON.stringify()</h3>\n<p>之前 JSON 字符串中包含行分隔符 <code>\\u2028</code> 或 段落分隔符 <code>\\u2029</code> 时, 调用 <code>JSON.parse()</code> 解析会报错, 修复了这个错误.</p>\n<p>之前对于无效的 UTF-16 字符编码, <code>JSON.stringify()</code> 会被替换为无意义的特殊字符, 现在修复了这个错误:</p>\n<pre><code class=\"language-jsx\">JSON.stringify(\"\\uD83D\")\n// 之前: '\"�\"'\n// 目前: '\"\\\\ud83d\"'\n</code></pre>\n<h3 id=\"arraysort更加稳定\" style=\"position:relative;\"><a href=\"#arraysort%E6%9B%B4%E5%8A%A0%E7%A8%B3%E5%AE%9A\" aria-label=\"arraysort更加稳定 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Array.sort()更加稳定</h3>\n<p>之前的规范允许不稳定的排序算法如快排, 目前主流浏览器都使用稳定的排序算法, 对于传入的比较算法计算结果等于 0 的情况也能保持顺序稳定.</p>\n<h3 id=\"functiontostring-重新修订\" style=\"position:relative;\"><a href=\"#functiontostring-%E9%87%8D%E6%96%B0%E4%BF%AE%E8%AE%A2\" aria-label=\"functiontostring 重新修订 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Function.toString() 重新修订</h3>\n<p>之前的 <code>Function.toString()</code> 只返回函数主体, 丢失了原始的注释和空格等信息.</p>\n<p>现在 <code>Function.toString()</code> 返回的结果与函数编写的一致.</p>\n<h2 id=\"es-2018\" style=\"position:relative;\"><a href=\"#es-2018\" aria-label=\"es 2018 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>ES 2018</h2>\n<h3 id=\"for-awaitof\" style=\"position:relative;\"><a href=\"#for-awaitof\" aria-label=\"for awaitof permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>for await...of</h3>\n<p>用于遍历异步可迭代对象(也可遍历同步可迭代对象).</p>\n<p>需要放在 <code>async function</code> 内部.</p>\n<pre><code class=\"language-jsx\">// 一个异步可迭代对象\nconst asyncIterable = {\n  [Symbol.asyncIterator]() {\n    return {\n      i: 0,\n      next() {\n        if (this.i &#x3C; 3) {\n          return Promise.resolve({ value: this.i++, done: false })\n        }\n\n        return Promise.resolve({ done: true })\n      },\n    }\n  },\n}\n// 遍历异步可迭代对象\n;(async function () {\n  for await (n of asyncIterable) {\n    console.log(n)\n  }\n})()\n</code></pre>\n<h3 id=\"promisefinally\" style=\"position:relative;\"><a href=\"#promisefinally\" aria-label=\"promisefinally permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Promise.finally()</h3>\n<p>当 Promise 执行结束时, 无论结果是 fulfilled 还是 rejected, 都会执行 finally 回调.</p>\n<pre><code class=\"language-jsx\">new Promise(...)\n    .then(...)\n    .catch(...)\n    .finally(...);\n</code></pre>\n<h3 id=\"object-rest-properties\" style=\"position:relative;\"><a href=\"#object-rest-properties\" aria-label=\"object rest properties permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Object Rest Properties</h3>\n<p>对象剩余属性:</p>\n<pre><code class=\"language-jsx\">let obj = { a: \"aa\", b: 30, c: true, d: \"\" }\nlet { a, b, ...others } = obj\na // \"aa\"\nb // 30\nothers // { c: true, d: \"\" }\n</code></pre>\n<h3 id=\"new-regexp-features\" style=\"position:relative;\"><a href=\"#new-regexp-features\" aria-label=\"new regexp features permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>New RegExp Features</h3>\n<p>新增 4 个 RegExp 新特性:</p>\n<ul>\n<li>Unicode 属性转义 <code>\\p{...}</code></li>\n<li>后行断言(lookbehind assertion) <code>(?&#x3C;=...)</code> <code>(?&#x3C;!)</code></li>\n<li>可命名捕获组 <code>(?&#x3C;name>...)</code></li>\n<li>s (dotAll) Flag, 使用 <code>s</code> 标志激活 <code>.</code> 字符匹配任意一个字符(dotAll 模式)</li>\n</ul>\n<h2 id=\"es-2017\" style=\"position:relative;\"><a href=\"#es-2017\" aria-label=\"es 2017 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>ES 2017</h2>\n<h3 id=\"string-padding\" style=\"position:relative;\"><a href=\"#string-padding\" aria-label=\"string padding permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>String Padding</h3>\n<p>使用另一个字符串(重复)填充当前字符串, 以达到指定长度</p>\n<ul>\n<li><code>padStart</code> 左侧填充</li>\n<li><code>padEnd</code> 右侧填充</li>\n</ul>\n<pre><code class=\"language-jsx\">\"abc\".padStart(10) // \"       abc\", 默认填充空格\n\"abc\".padEnd(10) // \"abc       \", 右侧填充\n\"abc\".padStart(10, \"foo\") // \"foofoofabc\", 用指定字符重复填充\n\"abc\".padStart(5, \"12345\") // \"12abc\", 多余字符丢弃\n\"abc\".padStart(2) // \"abc\", 若长度小于当前字符串则不变\n</code></pre>\n<h3 id=\"objectentries\" style=\"position:relative;\"><a href=\"#objectentries\" aria-label=\"objectentries permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Object.entries()</h3>\n<p>返回对象自身(不包括原型链)可枚举属性的键值对数组:</p>\n<pre><code class=\"language-jsx\">let o = { a: \"aaa\", b: 20 }\nconsole.log(Object.entries(o)) // [['a', 'aaa'], ['b', 20]]\nfor (let [key, value] of Object.entries(o)) {\n  console.log(`${key}: ${value}`)\n}\n</code></pre>\n<p>与 <code>for..in</code> 循环的顺序一致, 但 <code>for..in</code> 循环会枚举原型链中的属性.</p>\n<h3 id=\"objectvalues\" style=\"position:relative;\"><a href=\"#objectvalues\" aria-label=\"objectvalues permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Object.values()</h3>\n<p>返回对象自身的所有可枚举属性值的数组:</p>\n<pre><code class=\"language-jsx\">let o = { a: \"aaa\", b: 20 }\nconsole.log(Object.values(o)) // [\"aaa\", 20]\n</code></pre>\n<h3 id=\"async-functions\" style=\"position:relative;\"><a href=\"#async-functions\" aria-label=\"async functions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Async Functions</h3>\n<p>使用 <code>async</code> <code>await</code> 关键字更简洁地书写基于 <code>Promise</code> 的异步行为.</p>\n<h3 id=\"objectgetownpropertydescriptor\" style=\"position:relative;\"><a href=\"#objectgetownpropertydescriptor\" aria-label=\"objectgetownpropertydescriptor permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Object.getOwnPropertyDescriptor()</h3>\n<p>获取对象的一个自有属性的属性描述符:</p>\n<pre><code class=\"language-jsx\">const obj = { a: \"aaa\" }\nObject.getOwnPropertyDescriptor(obj, \"a\")\n// {value: 'aaa', writable: true, enumerable: true, configurable: true}\n</code></pre>\n<h3 id=\"函数参数列表中的尾随逗号\" style=\"position:relative;\"><a href=\"#%E5%87%BD%E6%95%B0%E5%8F%82%E6%95%B0%E5%88%97%E8%A1%A8%E4%B8%AD%E7%9A%84%E5%B0%BE%E9%9A%8F%E9%80%97%E5%8F%B7\" aria-label=\"函数参数列表中的尾随逗号 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>函数参数列表中的尾随逗号</h3>\n<p>允许在函数声明和函数调用的参数列表中使用尾随逗号:</p>\n<pre><code class=\"language-jsx\">const func = (v1, v2,) => {...};\nfunc(\"t1\", \"t2\",);\n</code></pre>\n<p>同时也支持对象字面量和数组字面量后的逗号.</p>\n<h3 id=\"sharedarraybuffer-和-atomics\" style=\"position:relative;\"><a href=\"#sharedarraybuffer-%E5%92%8C-atomics\" aria-label=\"sharedarraybuffer 和 atomics permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>SharedArrayBuffer 和 Atomics</h3>\n<p>WebWorkers 可以创建多线程程序, 使用 <code>SharedArrayBuffer</code> 创建共享数组缓冲区, 使得多个 workers 和主线程之间可以共享数据.</p>\n<p>全局对象 <code>Atomics</code> 提供了一组静态方法对 <code>SharedArrayBuffer</code> 和 <code>ArrayBuffer</code> 进行原子操作, 使得多个线程可以按规定顺序安全地读写同一位置的数据.</p>\n<blockquote>\n<p>为了防止 Spectre 漏洞, 所有主流浏览器默认禁用 SharedArrayBuffer .</p>\n</blockquote>\n<h2 id=\"es-2016\" style=\"position:relative;\"><a href=\"#es-2016\" aria-label=\"es 2016 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>ES 2016</h2>\n<h3 id=\"求幂运算符-\" style=\"position:relative;\"><a href=\"#%E6%B1%82%E5%B9%82%E8%BF%90%E7%AE%97%E7%AC%A6-\" aria-label=\"求幂运算符  permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>求幂运算符 **</h3>\n<p><code>let x = 2 ** 5;</code></p>\n<p>等价于 <code>Math.pow(x, y)</code></p>\n<p>“幂等”运算符 <code>**=</code> , 如:</p>\n<pre><code class=\"language-python\">let x = 5;\nx **= 2; // 相当于x = x ** 2\n</code></pre>\n<h3 id=\"arrayincludes\" style=\"position:relative;\"><a href=\"#arrayincludes\" aria-label=\"arrayincludes permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Array.includes()</h3>\n<pre><code class=\"language-python\">let arr = [\"1\", \"2\", \"3\"];\narr.includes(\"1\");  // true\narr.includes(\"4\");  // false\n</code></pre>\n<h2 id=\"es6-es2015\" style=\"position:relative;\"><a href=\"#es6-es2015\" aria-label=\"es6 es2015 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>ES6 (ES2015)</h2>\n<h3 id=\"关键字和类型\" style=\"position:relative;\"><a href=\"#%E5%85%B3%E9%94%AE%E5%AD%97%E5%92%8C%E7%B1%BB%E5%9E%8B\" aria-label=\"关键字和类型 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>关键字和类型</h3>\n<ul>\n<li><code>let</code> 与 <code>const</code> 声明</li>\n<li>箭头函数</li>\n<li>\n<p><code>for/of</code> 遍历可迭代的数据结构: Array, String, Map, NodeList 等</p>\n<ul>\n<li>区分 <code>for/in</code> : 遍历所有可枚举属性, 适用于遍历 Object 属性</li>\n</ul>\n</li>\n<li><code>Map</code> 对象</li>\n<li><code>Set</code> 对象</li>\n<li><code>class</code> \"面向对象\"相关方法实现</li>\n<li><code>Promise</code></li>\n<li><code>Symbol</code> 基本类型</li>\n</ul>\n<h3 id=\"function\" style=\"position:relative;\"><a href=\"#function\" aria-label=\"function permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Function</h3>\n<ul>\n<li>Function 参数默认值 <code>function fn(x = 2){...}</code></li>\n<li>Function 剩余参数 <code>function fn(a, b, ...others) {...}</code></li>\n</ul>\n<h3 id=\"string\" style=\"position:relative;\"><a href=\"#string\" aria-label=\"string permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>String</h3>\n<ul>\n<li><code>String.includes()</code></li>\n<li><code>String.startsWith()</code> <code>String.endsWith()</code></li>\n</ul>\n<h3 id=\"array\" style=\"position:relative;\"><a href=\"#array\" aria-label=\"array permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Array</h3>\n<ul>\n<li><code>Array.from()</code> 从具有长度或可迭代的对象创建数组, 如 Set, String 等</li>\n<li><code>Array.keys()</code> 返回数组的索引迭代器</li>\n<li><code>Array.find()</code> <code>Array.findIndex()</code> 返回满足测试函数的第一个元素 / 元素索引.</li>\n</ul>\n<h3 id=\"math\" style=\"position:relative;\"><a href=\"#math\" aria-label=\"math permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Math</h3>\n<ul>\n<li><code>Math.trunc()</code> 截取整数部分</li>\n<li><code>Math.sign()</code> 返回数字的符号, 取值: 1, -1, 0, -0, NaN, 传入参数会被隐式转换为数字.</li>\n<li><code>Math.cbrt()</code> 立方根</li>\n<li><code>Math.log2()</code> <code>Math.log10()</code></li>\n</ul>\n<h3 id=\"number\" style=\"position:relative;\"><a href=\"#number\" aria-label=\"number permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Number</h3>\n<ul>\n<li><code>Number.EPSILON</code> 最小精度值, 两数之差小于此值可认为两数相等.</li>\n<li><code>Number.MIN_SAFE_INTEGER</code> <code>Number.MAX_SAFE_INTEGER</code> 安全整数范围</li>\n<li><code>Number.isInteger()</code> <code>Number.isSafeInteger()</code></li>\n</ul>\n<h3 id=\"global-methods\" style=\"position:relative;\"><a href=\"#global-methods\" aria-label=\"global methods permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Global Methods</h3>\n<ul>\n<li><code>isFinite()</code> 参数为 <code>Infinity</code> 或 <code>NaN</code> 是返回 <code>false</code>, 其他情况为 <code>true</code></li>\n<li><code>isNaN()</code></li>\n</ul>\n<h3 id=\"object\" style=\"position:relative;\"><a href=\"#object\" aria-label=\"object permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Object</h3>\n<ul>\n<li>\n<p><code>Object.entries()</code> 返回对象可枚举属性的键值对数组</p>\n<pre><code>const o = { a: \"aa\", b: 2 };\nconsole.log(Object.entries(o));  // [[\"a\", \"aa\"], [\"b\", 2]]\n</code></pre>\n</li>\n</ul>\n<h3 id=\"javascript-modules\" style=\"position:relative;\"><a href=\"#javascript-modules\" aria-label=\"javascript modules permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>JavaScript Modules</h3>\n<p><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules\">JavaScript modules - JavaScript | MDN</a></p>","frontmatter":{"title":"ES6+新特性扫盲","date":"September 11, 2021","description":"ES6(ES2015) - ES2021新增特性概览"}},"previous":{"fields":{"slug":"/html-pickup/"},"frontmatter":{"title":"HTML拾遗"}},"next":null},"pageContext":{"id":"65ea000a-b635-5aad-a0c8-b0e5d6edf37b","previousPostId":"ef71ee56-83e0-5b94-a891-f6d4118c0f7f","nextPostId":null}},"staticQueryHashes":["2841359383","3257411868"]}