text: import { _ as _export_sfc, c as createElementBlock, o as openBlock, a as createStaticVNode } from "./app.b24e24a6.js";
  const __pageData = '{"title":"Array","description":"","frontmatter":{},"headers":[{"level":2,"title":"push","slug":"push"},{"level":2,"title":"unshift","slug":"unshift"},{"level":2,"title":"pop","slug":"pop"},{"level":2,"title":"shift","slug":"shift"},{"level":2,"title":"reverse","slug":"reverse"},{"level":2,"title":"slice","slug":"slice"},{"level":2,"title":"map","slug":"map"},{"level":2,"title":"forEach","slug":"foreach"},{"level":2,"title":"join","slug":"join"},{"level":2,"title":"concat","slug":"concat"},{"level":2,"title":"fill","slug":"fill"},{"level":2,"title":"filter","slug":"filter"},{"level":2,"title":"include","slug":"include"},{"level":2,"title":"\u662F\u5426\u6539\u53D8\u539F\u6570\u7EC4","slug":"\u662F\u5426\u6539\u53D8\u539F\u6570\u7EC4"},{"level":3,"title":"\u6539\u53D8\u539F\u6570\u7EC4","slug":"\u6539\u53D8\u539F\u6570\u7EC4"},{"level":3,"title":"\u4E0D\u4F1A\u6539\u53D8\u539F\u6570\u7EC4","slug":"\u4E0D\u4F1A\u6539\u53D8\u539F\u6570\u7EC4"},{"level":2,"title":"\u6570\u7EC4\u53BB\u91CD","slug":"\u6570\u7EC4\u53BB\u91CD"},{"level":2,"title":"\u7A00\u758F\u6570\u7EC4\u4E0Ehole","slug":"\u7A00\u758F\u6570\u7EC4\u4E0Ehole"},{"level":3,"title":"\u7A00\u758F\u6570\u7EC4\u662F\u4EC0\u4E48","slug":"\u7A00\u758F\u6570\u7EC4\u662F\u4EC0\u4E48"},{"level":3,"title":"JavaScript\u6570\u7EC4\u5929\u751F\u5C31\u662F\u7A00\u758F\u6570\u7EC4","slug":"javascript\u6570\u7EC4\u5929\u751F\u5C31\u662F\u7A00\u758F\u6570\u7EC4"},{"level":3,"title":"JavaScript\u6570\u7EC4\u7A00\u758F\u7279\u6027\u5E26\u6765\u7684\u201C\u602A\u5F02\u73B0\u8C61\u201D","slug":"javascript\u6570\u7EC4\u7A00\u758F\u7279\u6027\u5E26\u6765\u7684\u201C\u602A\u5F02\u73B0\u8C61\u201D"},{"level":3,"title":"\u521D\u59CB\u5316\u65E0\u5B54\u6570\u7EC4\u7684\u65B9\u6CD5","slug":"\u521D\u59CB\u5316\u65E0\u5B54\u6570\u7EC4\u7684\u65B9\u6CD5"},{"level":3,"title":"Array.apply(null, Array(n))\u7684\u539F\u7406","slug":"array-apply-null-array-n-\u7684\u539F\u7406"}],"relativePath":"notes/1.basic/3.javaScript/11.Array.md","lastUpdated":1652939653935}';
  const _sfc_main = {};
  const _hoisted_1 = /* @__PURE__ */ createStaticVNode('<h1 id="array" tabindex="-1">Array <a class="header-anchor" href="#array" aria-hidden="true">#</a></h1><h2 id="push" tabindex="-1">push <a class="header-anchor" href="#push" aria-hidden="true">#</a></h2><p>\u5411\u6570\u7EC4\u7684\u672B\u5C3E\u6DFB\u52A0\u4E00\u4E2A\u6216\u591A\u4E2A\u5143\u7D20\uFF0C\u5E76\u8FD4\u56DE\u65B0\u7684\u957F\u5EA6\uFF0C <code>\u4F1A\u6539\u53D8\u539F\u6570\u7EC4</code></p><div class="language-js"><pre><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> arr </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> [</span><span style="color:#F78C6C;">1</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">2</span><span style="color:#A6ACCD;">]</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(arr</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">push</span><span style="color:#A6ACCD;">(</span><span style="color:#F78C6C;">3</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">4</span><span style="color:#A6ACCD;">)) </span><span style="color:#676E95;font-style:italic;">// 4</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(arr) </span><span style="color:#676E95;font-style:italic;">// [1, 2, 3, 4]</span></span>\n<span class="line"></span></code></pre></div><h2 id="unshift" tabindex="-1">unshift <a class="header-anchor" href="#unshift" aria-hidden="true">#</a></h2><p>\u5411\u6570\u7EC4\u7684\u5F00\u5934\u6DFB\u52A0\u4E00\u4E2A\u6216\u66F4\u591A\u5143\u7D20\uFF0C\u5E76\u8FD4\u56DE\u65B0\u7684\u957F\u5EA6\uFF0C <code>\u4F1A\u6539\u53D8\u539F\u6570\u7EC4</code></p><div class="language-js"><pre><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> arr </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> [</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">c</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">d</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;">]</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(arr</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">unshift</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">a</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">b</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;">)) </span><span style="color:#676E95;font-style:italic;">// 4</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(arr) </span><span style="color:#676E95;font-style:italic;">// [ &#39;a&#39;, &#39;b&#39;, &#39;c&#39;, &#39;d&#39; ]</span></span>\n<span class="line"></span></code></pre></div><h2 id="pop" tabindex="-1">pop <a class="header-anchor" href="#pop" aria-hidden="true">#</a></h2><p>\u5220\u9664\u6570\u7EC4\u7684\u6700\u540E\u4E00\u4E2A\u5143\u7D20\u5E76\u8FD4\u56DE\u5220\u9664\u7684\u5143\u7D20\uFF0C<code>\u4F1A\u6539\u53D8\u539F\u6570\u7EC4</code></p><div class="language-js"><pre><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> arr </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> [</span><span style="color:#F78C6C;">1</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">2</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">3</span><span style="color:#A6ACCD;">]</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(arr</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">pop</span><span style="color:#A6ACCD;">()) </span><span style="color:#676E95;font-style:italic;">// 3</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(arr) </span><span style="color:#676E95;font-style:italic;">// [ 1, 2 ]</span></span>\n<span class="line"></span></code></pre></div><h2 id="shift" tabindex="-1">shift <a class="header-anchor" href="#shift" aria-hidden="true">#</a></h2><p>\u5220\u9664\u6570\u7EC4\u7B2C\u4E00\u4E2A\u5143\u7D20\uFF0C\u8FD4\u56DE\u5F53\u524D\u5220\u9664\u7684\u5143\u7D20\uFF0C<code>\u4F1A\u6539\u53D8\u539F\u6570\u7EC4</code></p><div class="language-js"><pre><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> arr </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> [</span><span style="color:#F78C6C;">1</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">2</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">3</span><span style="color:#A6ACCD;">]</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(arr</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">shift</span><span style="color:#A6ACCD;">()) </span><span style="color:#676E95;font-style:italic;">// 1</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(arr) </span><span style="color:#676E95;font-style:italic;">// [2,3]</span></span>\n<span class="line"></span></code></pre></div><h2 id="reverse" tabindex="-1">reverse <a class="header-anchor" href="#reverse" aria-hidden="true">#</a></h2><p>\u98A0\u5012\u6570\u7EC4\u4E2D\u5143\u7D20\u7684\u987A\u5E8F\uFF0C\u8FD4\u56DE\u98A0\u5012\u987A\u5E8F\u7684\u6570\u7EC4\uFF0C<code>\u4F1A\u6539\u53D8\u539F\u6570\u7EC4</code></p><div class="language-js"><pre><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> arr </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> [</span><span style="color:#F78C6C;">1</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">2</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">3</span><span style="color:#A6ACCD;">]</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(arr</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">reverse</span><span style="color:#A6ACCD;">()) </span><span style="color:#676E95;font-style:italic;">//  [3, 2, 1]</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(arr) </span><span style="color:#676E95;font-style:italic;">//  [3, 2, 1]</span></span>\n<span class="line"></span></code></pre></div><h2 id="slice" tabindex="-1">slice <a class="header-anchor" href="#slice" aria-hidden="true">#</a></h2><p>\u6DFB\u52A0\u6216\u5220\u9664\u6570\u7EC4\u4E2D\u7684\u5143\u7D20</p><table><thead><tr><th style="text-align:left;">\u53C2\u6570</th><th style="text-align:left;">\u63CF\u8FF0</th></tr></thead><tbody><tr><td style="text-align:left;"><em>index</em></td><td style="text-align:left;">\u5FC5\u9700\u3002\u89C4\u5B9A\u4ECE\u4F55\u5904\u6DFB\u52A0/\u5220\u9664\u5143\u7D20\u3002 \u8BE5\u53C2\u6570\u662F\u5F00\u59CB\u63D2\u5165\u548C\uFF08\u6216\uFF09\u5220\u9664\u7684\u6570\u7EC4\u5143\u7D20\u7684\u4E0B\u6807\uFF0C\u5FC5\u987B\u662F\u6570\u5B57\u3002</td></tr><tr><td style="text-align:left;"><em>howmany</em></td><td style="text-align:left;">\u53EF\u9009\u3002\u89C4\u5B9A\u5E94\u8BE5\u5220\u9664\u591A\u5C11\u5143\u7D20\u3002\u5FC5\u987B\u662F\u6570\u5B57\uFF0C\u4F46\u53EF\u4EE5\u662F &quot;0&quot;\u3002 \u5982\u679C\u672A\u89C4\u5B9A\u6B64\u53C2\u6570\uFF0C\u5219\u5220\u9664\u4ECE index \u5F00\u59CB\u5230\u539F\u6570\u7EC4\u7ED3\u5C3E\u7684\u6240\u6709\u5143\u7D20\u3002</td></tr><tr><td style="text-align:left;"><em>item1</em>, ..., <em>itemX</em></td><td style="text-align:left;">\u53EF\u9009\u3002\u8981\u6DFB\u52A0\u5230\u6570\u7EC4\u7684\u65B0\u5143\u7D20</td></tr></tbody></table><div class="language-js"><pre><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> fruits </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> [</span><span style="color:#F78C6C;">1</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">2</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">3</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">4</span><span style="color:#A6ACCD;">]</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(fruits</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">splice</span><span style="color:#A6ACCD;">(</span><span style="color:#F78C6C;">2</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">0</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">5</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">6</span><span style="color:#A6ACCD;">)) </span><span style="color:#676E95;font-style:italic;">// []</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(fruits)</span></span>\n<span class="line"></span></code></pre></div><h2 id="map" tabindex="-1">map <a class="header-anchor" href="#map" aria-hidden="true">#</a></h2><p>map \u65B9\u6CD5\u904D\u5386\u6BCF\u4E2A\u6570\u7EC4\u5143\u7D20\u5E76\u8FDB\u884C\u4F9D\u6B21\u5904\u7406\u540E\uFF0C\u8FD4\u56DE\u4E00\u4E2A\u65B0\u6570\u7EC4\uFF0C\u6240\u4EE5\u4F7F\u7528 map \u65F6\u9700\u8981\u8FD4\u56DE\u503C\uFF0C\u5E76\u5B9A\u4E49\u53D8\u91CF\u63A5\u6536\u8FD4\u56DE\u503C</p><p>map \u65B9\u6CD5\u4E0D\u4F1A\u6539\u53D8\u539F\u6570\u7EC4</p><p>\u63A5\u53D7\u4E00\u4E2A\u51FD\u6570\uFF0C\u51FD\u6570\u6709\u4E09\u4E2A\u53C2\u6570\uFF0C\u4E00\u4E2A\u5FC5\u9009\uFF0C\u4E24\u4E2A\u53EF\u9009</p><div class="language-js"><pre><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> arr </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> [</span><span style="color:#F78C6C;">1</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">2</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">3</span><span style="color:#A6ACCD;">]</span></span>\n<span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> a </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> arr</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">map</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">(</span><span style="color:#A6ACCD;">a</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> index</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> arr</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">=&gt;</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span></span>\n<span class="line"><span style="color:#F07178;">  </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">a</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">+</span><span style="color:#F07178;"> </span><span style="color:#F78C6C;">1</span></span>\n<span class="line"><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">)</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(a) </span><span style="color:#676E95;font-style:italic;">// [ 2, 3, 4 ]</span></span>\n<span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> b </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> arr</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">map</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">(</span><span style="color:#A6ACCD;">a</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> index</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> arr</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">=&gt;</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span></span>\n<span class="line"><span style="color:#F07178;">  </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">index</span></span>\n<span class="line"><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">)</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(b) </span><span style="color:#676E95;font-style:italic;">// [0, 1, 2]</span></span>\n<span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> c </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> arr</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">map</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">(</span><span style="color:#A6ACCD;">a</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> index</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> arr</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">=&gt;</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span></span>\n<span class="line"><span style="color:#F07178;">  </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">arr</span></span>\n<span class="line"><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">)</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(a) </span><span style="color:#676E95;font-style:italic;">// [[1, 2, 3],[1, 2, 3],[1, 2, 3]]</span></span>\n<span class="line"></span></code></pre></div><h2 id="foreach" tabindex="-1">forEach <a class="header-anchor" href="#foreach" aria-hidden="true">#</a></h2><p>\u904D\u5386\u6BCF\u4E2A\u6570\u7EC4\u5143\u7D20\uFF0C\u548C map \u4E00\u6837\u90FD\u4E0D\u4F1A\u4FEE\u6539\u539F\u6570\u7EC4\uFF0C\u533A\u522B\u5728\u4E8E\u6CA1\u6709\u8FD4\u56DE\u503C\uFF0C\u8FD4\u56DE\u503C\u662F undefined\uFF0C\u6240\u4EE5\u4F7F\u7528 forEach \u4E0D\u9700\u8981\u8FD4\u56DE\u503C</p><p>\u53C2\u6570\u662F\u4E00\u4E2A\u51FD\u6570\uFF0C\u51FD\u6570\u6709\u4E09\u4E2A\u53C2\u6570\uFF0C\u4E00\u4E2A\u5FC5\u9009\uFF0C\u4E24\u4E2A\u53EF\u9009</p><p>\u7528\u6CD5\u793A\u4F8B 1\uFF1A\u4FEE\u6539\u6570\u7EC4\u5E76 push \u5230\u4E00\u4E2A\u65B0\u6570\u7EC4</p><div class="language-js"><pre><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> arr </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> [</span><span style="color:#F78C6C;">1</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">2</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">3</span><span style="color:#A6ACCD;">]</span></span>\n<span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> newarr </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> [] </span><span style="color:#676E95;font-style:italic;">//\u5F53\u524D\u7684\u5143\u7D20 index\u7D22\u5F15  \u6570\u7EC4\u5BF9\u8C61\u672C\u8EAB</span></span>\n<span class="line"><span style="color:#A6ACCD;">arr</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">forEach</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">(</span><span style="color:#A6ACCD;">a</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> index</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> arr</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">=&gt;</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span></span>\n<span class="line"><span style="color:#F07178;">  </span><span style="color:#A6ACCD;">a</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">=</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">a</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">+</span><span style="color:#F07178;"> </span><span style="color:#F78C6C;">3</span></span>\n<span class="line"><span style="color:#F07178;">  </span><span style="color:#A6ACCD;">newarr</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">push</span><span style="color:#F07178;">(</span><span style="color:#A6ACCD;">a</span><span style="color:#F07178;">)</span></span>\n<span class="line"><span style="color:#F07178;">  </span><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#F07178;">(</span><span style="color:#A6ACCD;">a</span><span style="color:#F07178;">) </span><span style="color:#676E95;font-style:italic;">// 4,5,6</span></span>\n<span class="line"><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">)</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(arr) </span><span style="color:#676E95;font-style:italic;">// [1,2,3]</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(newarr) </span><span style="color:#676E95;font-style:italic;">// [4,5,6]</span></span>\n<span class="line"></span></code></pre></div><p>\u7528\u6CD5\u793A\u4F8B 2\uFF1A\u8FC7\u6EE4\u6570\u7EC4\u5E76 push \u5230\u4E00\u4E2A\u65B0\u6570\u7EC4</p><div class="language-js"><pre><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> arr </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> [</span><span style="color:#F78C6C;">1</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">2</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">3</span><span style="color:#A6ACCD;">]</span></span>\n<span class="line"><span style="color:#C792EA;">let</span><span style="color:#A6ACCD;"> newarr </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> []</span></span>\n<span class="line"><span style="color:#A6ACCD;">arr</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">forEach</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">(</span><span style="color:#A6ACCD;">a</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">=&gt;</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span></span>\n<span class="line"><span style="color:#F07178;">  </span><span style="color:#89DDFF;font-style:italic;">if</span><span style="color:#F07178;"> (</span><span style="color:#A6ACCD;">a</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">==</span><span style="color:#F07178;"> </span><span style="color:#F78C6C;">2</span><span style="color:#F07178;">) </span><span style="color:#89DDFF;font-style:italic;">return</span></span>\n<span class="line"><span style="color:#F07178;">  </span><span style="color:#A6ACCD;">newarr</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">push</span><span style="color:#F07178;">(</span><span style="color:#A6ACCD;">a</span><span style="color:#F07178;">)</span></span>\n<span class="line"><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">)</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(newarr) </span><span style="color:#676E95;font-style:italic;">// [ 1, 3 ]</span></span>\n<span class="line"></span></code></pre></div><h2 id="join" tabindex="-1">join <a class="header-anchor" href="#join" aria-hidden="true">#</a></h2><p>\u6570\u7EC4\u8F6C\u5B57\u7B26\u4E32</p><div class="language-js"><pre><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> arr </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> [</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">a</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">b</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">c</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">d</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;">]</span></span>\n<span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> string </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> arr</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">join</span><span style="color:#A6ACCD;">() </span><span style="color:#676E95;font-style:italic;">// a,b,c,d</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(string)</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">typeof</span><span style="color:#A6ACCD;"> arr) </span><span style="color:#676E95;font-style:italic;">// object</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">typeof</span><span style="color:#A6ACCD;"> string) </span><span style="color:#676E95;font-style:italic;">// string</span></span>\n<span class="line"></span></code></pre></div><h2 id="concat" tabindex="-1">concat <a class="header-anchor" href="#concat" aria-hidden="true">#</a></h2><p>concat() \u65B9\u6CD5\u7528\u4E8E\u8FDE\u63A5\u4E24\u4E2A\u6216\u591A\u4E2A\u6570\u7EC4\u3002</p><div class="language-js"><pre><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> a </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> [</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">a</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;">]</span></span>\n<span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> b </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> [</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">b</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">c</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">d</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">e</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;">]</span></span>\n<span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> f </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> [</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">f</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;">]</span></span>\n<span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> arr </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> a</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">concat</span><span style="color:#A6ACCD;">(b</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> f)</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(arr) </span><span style="color:#676E95;font-style:italic;">// [ &#39;a&#39;, &#39;b&#39;, &#39;c&#39;, &#39;d&#39;, &#39;e&#39;, &#39;f&#39; ]</span></span>\n<span class="line"></span></code></pre></div><h2 id="fill" tabindex="-1">fill <a class="header-anchor" href="#fill" aria-hidden="true">#</a></h2><p>fill \u53EF\u4EE5\u63D2\u5165\u6570\u7EC4\u6570\u636E,Array(num)\u53EF\u4EE5\u4EA7\u751F num \u5927\u5C0F\u7684\u6570\u7EC4\uFF0CArray(num).fill(a)\u6BCF\u6B21\u751F\u6210\u4E00\u4E2A\u6570\u7EC4\u5143\u7D20\u65F6\u90FD\u4F1A\u8C03\u7528 fill \u65B9\u6CD5\u63D2\u5165\u6570\u636E</p><div class="language-js"><pre><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> a </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">A</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">age</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">20</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">sex</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">\u7537</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">}</span></span>\n<span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> b </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Array</span><span style="color:#A6ACCD;">(</span><span style="color:#F78C6C;">1</span><span style="color:#A6ACCD;">)</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">fill</span><span style="color:#A6ACCD;">(a)</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(b) </span><span style="color:#676E95;font-style:italic;">// [ { name: &#39;A&#39;, age: 20, sex: &#39;\u7537&#39; } ]</span></span>\n<span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> c </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> []</span></span>\n<span class="line"><span style="color:#A6ACCD;">c</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">push</span><span style="color:#A6ACCD;">(a)</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(c) </span><span style="color:#676E95;font-style:italic;">// [ { name: &#39;A&#39;, age: 20, sex: &#39;\u7537&#39; } ]</span></span>\n<span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> d </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Array</span><span style="color:#A6ACCD;">(</span><span style="color:#F78C6C;">3</span><span style="color:#A6ACCD;">)</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">fill</span><span style="color:#A6ACCD;">(a)</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(d) </span><span style="color:#676E95;font-style:italic;">//[ { name: &#39;A&#39;, age: 20, sex: &#39;\u7537&#39; } ,{ name: &#39;A&#39;, age: 20, sex: &#39;\u7537&#39; } ,{ name: &#39;A&#39;, age: 20, sex: &#39;\u7537&#39; } ]</span></span>\n<span class="line"></span></code></pre></div><h2 id="filter" tabindex="-1">filter <a class="header-anchor" href="#filter" aria-hidden="true">#</a></h2><p>\u904D\u5386\u6570\u7EC4\u5143\u7D20\uFF0C\u8FD4\u56DE\u7B26\u5408\u6761\u4EF6\u7684\u6570\u636E\uFF0C\u4E3A true \u7684\u4FDD\u7559\uFF0C\u4E3A false \u7684\u6EDA\u728A\u5B50</p><p>\u793A\u4F8B\uFF1A\u8FD4\u56DE\u5076\u6570</p><div class="language-js"><pre><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> a </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> [</span><span style="color:#F78C6C;">1</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">2</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">3</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">4</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">5</span><span style="color:#A6ACCD;">]</span></span>\n<span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> b </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> a</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">filter</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">(</span><span style="color:#A6ACCD;">item</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">=&gt;</span><span style="color:#A6ACCD;"> item </span><span style="color:#89DDFF;">%</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">2</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">===</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">0</span><span style="color:#A6ACCD;">)</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(b) </span><span style="color:#676E95;font-style:italic;">//[2,4]</span></span>\n<span class="line"></span></code></pre></div><p>\u793A\u4F8B\uFF1A\u76F4\u63A5\u4F7F\u7528 true/false \u7684\u5B57\u6BB5\u6765\u8FC7\u6EE4</p><div class="language-js"><pre><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> a </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> [</span></span>\n<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">{</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">id</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">1</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">is</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#FF9CAC;">true</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">},</span></span>\n<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">{</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">id</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">2</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">is</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#FF9CAC;">true</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">},</span></span>\n<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">{</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">id</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">3</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">is</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#FF9CAC;">false</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">},</span></span>\n<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">{</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">id</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">4</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">is</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#FF9CAC;">true</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">},</span></span>\n<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">{</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">id</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">5</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">is</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#FF9CAC;">false</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">}</span></span>\n<span class="line"><span style="color:#A6ACCD;">]</span></span>\n<span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> b </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> a</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">filter</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">(</span><span style="color:#A6ACCD;">item</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">=&gt;</span><span style="color:#A6ACCD;"> item</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">is)</span></span>\n<span class="line"><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(b) </span><span style="color:#676E95;font-style:italic;">//[ { id: 1, is: true }, { id: 2, is: true }, { id: 4, is: true } ]</span></span>\n<span class="line"></span></code></pre></div><h2 id="include" tabindex="-1">include <a class="header-anchor" href="#include" aria-hidden="true">#</a></h2><div class="language-js"><pre><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> foo </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">foo</span><span style="color:#89DDFF;">&#39;</span></span>\n<span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> bar </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">bar</span><span style="color:#89DDFF;">&#39;</span></span>\n<span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> arr </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> [foo</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> bar]</span></span>\n<span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> test </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">foo</span><span style="color:#89DDFF;">&#39;</span></span>\n<span class="line"><span style="color:#89DDFF;font-style:italic;">if</span><span style="color:#A6ACCD;"> (arr</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">includes</span><span style="color:#A6ACCD;">(test)) console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">TRUE</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;">)</span></span>\n<span class="line"></span></code></pre></div><h2 id="\u662F\u5426\u6539\u53D8\u539F\u6570\u7EC4" tabindex="-1">\u662F\u5426\u6539\u53D8\u539F\u6570\u7EC4 <a class="header-anchor" href="#\u662F\u5426\u6539\u53D8\u539F\u6570\u7EC4" aria-hidden="true">#</a></h2><h3 id="\u6539\u53D8\u539F\u6570\u7EC4" tabindex="-1">\u6539\u53D8\u539F\u6570\u7EC4 <a class="header-anchor" href="#\u6539\u53D8\u539F\u6570\u7EC4" aria-hidden="true">#</a></h3><h4 id="\u6DFB\u52A0\u5143\u7D20-\u8FD4\u56DE\u65B0\u7684\u957F\u5EA6" tabindex="-1">\u6DFB\u52A0\u5143\u7D20(\u8FD4\u56DE\u65B0\u7684\u957F\u5EA6) <a class="header-anchor" href="#\u6DFB\u52A0\u5143\u7D20-\u8FD4\u56DE\u65B0\u7684\u957F\u5EA6" aria-hidden="true">#</a></h4><ul><li><code>push</code> \u628A\u5143\u7D20\u6DFB\u52A0\u5230\u6570\u7EC4\u5C3E\u90E8</li><li><code>unshift</code> \u628A\u5143\u7D20\u6DFB\u52A0\u6570\u7EC4\u5934\u90E8</li></ul><h4 id="\u5220\u9664\u5143\u7D20-\u8FD4\u56DE\u88AB\u5220\u9664\u7684\u5143\u7D20" tabindex="-1">\u5220\u9664\u5143\u7D20(\u8FD4\u56DE\u88AB\u5220\u9664\u7684\u5143\u7D20) <a class="header-anchor" href="#\u5220\u9664\u5143\u7D20-\u8FD4\u56DE\u88AB\u5220\u9664\u7684\u5143\u7D20" aria-hidden="true">#</a></h4><ul><li><code>pop</code> \u5220\u9664\u6570\u7EC4\u6700\u540E\u4E00\u4E2A\u5143\u7D20</li><li><code>shift </code>\u5220\u9664\u6570\u7EC4\u7B2C\u4E00\u4E2A\u5143\u7D20</li></ul><h4 id="\u98A0\u5012\u987A\u5E8F" tabindex="-1">\u98A0\u5012\u987A\u5E8F <a class="header-anchor" href="#\u98A0\u5012\u987A\u5E8F" aria-hidden="true">#</a></h4><ul><li><code>reverse</code>\u98A0\u5012\u6570\u7EC4\u5143\u7D20\u987A\u5E8F</li></ul><h4 id="\u63D2\u5165\u3001\u5220\u9664\u3001\u66FF\u6362\u6570\u7EC4\u5143\u7D20-\u8FD4\u56DE\u88AB\u5220\u9664\u7684\u6570\u7EC4\uFF09" tabindex="-1">\u63D2\u5165\u3001\u5220\u9664\u3001\u66FF\u6362\u6570\u7EC4\u5143\u7D20:(\u8FD4\u56DE\u88AB\u5220\u9664\u7684\u6570\u7EC4\uFF09 <a class="header-anchor" href="#\u63D2\u5165\u3001\u5220\u9664\u3001\u66FF\u6362\u6570\u7EC4\u5143\u7D20-\u8FD4\u56DE\u88AB\u5220\u9664\u7684\u6570\u7EC4\uFF09" aria-hidden="true">#</a></h4><ul><li><code>splice</code></li></ul><h4 id="\u6392\u5E8F" tabindex="-1">\u6392\u5E8F <a class="header-anchor" href="#\u6392\u5E8F" aria-hidden="true">#</a></h4><ul><li><code>sort</code> \u5BF9\u6570\u7EC4\u5143\u7D20\u8FDB\u884C\u6392\u5E8F</li></ul><h3 id="\u4E0D\u4F1A\u6539\u53D8\u539F\u6570\u7EC4" tabindex="-1">\u4E0D\u4F1A\u6539\u53D8\u539F\u6570\u7EC4 <a class="header-anchor" href="#\u4E0D\u4F1A\u6539\u53D8\u539F\u6570\u7EC4" aria-hidden="true">#</a></h3><ul><li><code>concat</code> \u8FDE\u63A5\u4E24\u4E2A\u6216\u66F4\u591A\u6570\u7EC4\uFF0C\u8FD4\u56DE\u7ED3\u679C</li><li><code>every</code> \u68C0\u6D4B\u6570\u7EC4\u4E2D\u6BCF\u4E2A\u5143\u7D20\u662F\u5426\u90FD\u7B26\u5408\u8981\u6C42</li><li><code>some</code> \u68C0\u6D4B\u6570\u7EC4\u4E2D\u662F\u5426\u6709\u5143\u7D20\u7B26\u5408\u8981\u6C42</li><li><code>filter</code> \u6311\u9009\u6570\u7EC4\u4E2D\u7B26\u5408\u6761\u4EF6\u7684\u5E76\u8FD4\u56DE\u7B26\u5408\u8981\u6C42\u7684\u6570\u7EC4</li><li><code>join</code> \u628A\u6570\u7EC4\u7684\u6240\u6709\u5143\u7D20\u653E\u5230\u4E00\u4E2A\u5B57\u7B26\u4E32</li><li><code>toString</code> \u628A\u6570\u7EC4\u8F6C\u6210\u5B57\u7B26\u4E32</li><li><code>slice</code> \u622A\u53D6\u4E00\u6BB5\u6570\u7EC4\uFF0C\u8FD4\u56DE\u65B0\u6570\u7EC4</li><li><code>indexOf </code>\u641C\u7D22\u6570\u7EC4\u4E2D\u7684\u5143\u7D20\uFF0C\u5E76\u8FD4\u56DE\u6240\u5728\u7684\u4F4D\u7F6E</li></ul><h2 id="\u6570\u7EC4\u53BB\u91CD" tabindex="-1">\u6570\u7EC4\u53BB\u91CD <a class="header-anchor" href="#\u6570\u7EC4\u53BB\u91CD" aria-hidden="true">#</a></h2><div class="language-js"><pre><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> set </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">new</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Set</span><span style="color:#A6ACCD;">([</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">foo</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">bar</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">baz</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">foo</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;">])</span></span>\n<span class="line"><span style="color:#FFCB6B;">Array</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">from</span><span style="color:#A6ACCD;">(set) </span><span style="color:#676E95;font-style:italic;">// [ &quot;foo&quot;, &quot;bar&quot;, &quot;baz&quot; ]</span></span>\n<span class="line"></span></code></pre></div><h2 id="\u7A00\u758F\u6570\u7EC4\u4E0Ehole" tabindex="-1">\u7A00\u758F\u6570\u7EC4\u4E0Ehole <a class="header-anchor" href="#\u7A00\u758F\u6570\u7EC4\u4E0Ehole" aria-hidden="true">#</a></h2><p>\u5728\u7EDD\u5927\u591A\u6570JavaScript\u7684\u5B9E\u73B0\u4E2D\uFF0C\u6570\u7EC4\u662F\u7A00\u758F\u7684\uFF0C\u6211\u4EEC\u53EF\u4EE5\u8BA4\u4E3Ajs\u7684\u6570\u7EC4\u90FD\u662F\u7A00\u758F\u7684\uFF08\u867D\u7136ES\u6807\u51C6\u5E76\u6CA1\u6709\u8FD9\u6837\u89C4\u5B9A\uFF09</p><h3 id="\u7A00\u758F\u6570\u7EC4\u662F\u4EC0\u4E48" tabindex="-1">\u7A00\u758F\u6570\u7EC4\u662F\u4EC0\u4E48 <a class="header-anchor" href="#\u7A00\u758F\u6570\u7EC4\u662F\u4EC0\u4E48" aria-hidden="true">#</a></h3><p>\u7A00\u758F\u6570\u7EC4\u4E0E\u5BC6\u96C6\u6570\u7EC4\u6700\u5927\u7684\u4E0D\u540C\uFF0C\u5C31\u662F\u7A00\u758F\u6570\u7EC4\u4E2D\u53EF\u4EE5\u6709**<code>\u5B54</code><strong>(</strong><code>hole</code>**)\u3002\u5B54\u662F\u903B\u8F91\u4E0A\u5B58\u5728\u4E8E\u6570\u7EC4\u4E2D\uFF0C\u4F46\u7269\u7406\u4E0A\u4E0D\u5B58\u5728\u4E0E\u5185\u5B58\u4E2D\u7684\u90A3\u4E9B\u6570\u7EC4\u9879\u3002\u5728\u90A3\u4E9B\u4EC5\u6709\u5C11\u90E8\u5206\u9879\u88AB\u4F7F\u7528\u7684\u6570\u7EC4\u4E2D\uFF0C\u5B54\u53EF\u4EE5\u5927\u5927\u51CF\u5C11\u5185\u5B58\u7A7A\u95F4\u7684\u6D6A\u8D39\u3002\u6BD4\u5982\uFF0C\u6211\u4EEC\u8981\u8868\u793A\u4E00\u4E2A\u957F\u5EA6\u4E3A10000\u7684\u6570\u7EC4\uFF0C\u5B83\u7684\u6700\u540E\u4E00\u4E2A\u9879\u662F\u5B57\u7B26\u4E32&#39;a&#39;\u3002\u5982\u679C\u6309\u7167\u5BC6\u96C6\u6570\u7EC4\u7684\u505A\u6CD5\uFF0C\u6211\u4EEC\u9700\u8981\u5F00\u8F9F10000\u4E2A\u9879\u7684\u7A7A\u95F4\uFF0C\u67099999\u4E2A\u9879\u7684\u7A7A\u95F4\u90FD\u88AB\u6D6A\u8D39\u4E86\u3002\u800C\u5982\u679C\u6309\u7167\u7A00\u758F\u6570\u7EC4\u7684\u505A\u6CD5\uFF0C\u7A00\u758F\u6570\u7EC4\u53EA\u9700\u8981\u8BB0\u5F55\uFF1A\u201C\u6570\u7EC4\u7B2C10000\u4E2A\u9879\u7684\u503C\u4E3A&#39;a&#39;\u201D\uFF0C\u8FD9\u8282\u7701\u4E86\u5F88\u591A\u5185\u5B58\u7A7A\u95F4\u3002</p><h3 id="javascript\u6570\u7EC4\u5929\u751F\u5C31\u662F\u7A00\u758F\u6570\u7EC4" tabindex="-1">JavaScript\u6570\u7EC4\u5929\u751F\u5C31\u662F\u7A00\u758F\u6570\u7EC4 <a class="header-anchor" href="#javascript\u6570\u7EC4\u5929\u751F\u5C31\u662F\u7A00\u758F\u6570\u7EC4" aria-hidden="true">#</a></h3><p><strong>js\u6570\u7EC4\u5C31\u662F\u82E5\u5E72\u4E2A\u4E0B\u6807\uFF08\u6570\u5B57\uFF09\u4E0E\u503C\u4E4B\u95F4\u7684\u6620\u5C04</strong>\u3002\u4ECE\u4E0B\u6807x\u5230\u503Cy\u7684\u6620\u5C04\u8868\u793A\uFF1A<strong>\u201C\u6570\u7EC4\u7B2Cx\u4E2A\u9879\u7684\u503C\u4E3Ay\u201D</strong>\u3002\u8FD9\u5B9E\u9645\u4E0A\u5C31\u662F\u4E0A\u4F8B\u4E2D\u7A00\u758F\u6570\u7EC4\u7684\u8BB0\u5F55\u65B9\u6CD5</p><div class="language-js"><pre><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> a </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">new</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Array</span></span>\n<span class="line"></span></code></pre></div><p>\u5F97\u5230\u7684\u6570\u7EC4<code>a</code>\u4E2D\u53EA\u6709\u4E00\u4E2A\u5C5E\u6027length\uFF0C\u8BB0\u5F55\u4E86\u5B83\u7684\u957F\u5EA6\uFF0C\u4F46\u662F<strong>\u6CA1\u6709\u4EFB\u4F55\u4E0B\u6807\uFF08\u6570\u5B57\uFF09\u4E0E\u503C\u4E4B\u95F4\u7684\u6620\u5C04</strong>\u3002\u8FD9\u662F\u4E00\u4E2A\u53EA\u6709\u5B54\u7684\u6570\u7EC4</p><p>\u5982\u679C\u6267\u884C<code>a[1] = &#39;aaa&#39;</code>\uFF0C\u90A3\u4E48\u5B9E\u9645\u4E0A\u662F\u5728\u8FD9\u4E2A\u7A00\u758F\u6570\u7EC4\u4E2D\u589E\u52A0\u4E86\u4E00\u6761<strong>\u4ECE1\u5230&quot;aaa&quot;\u4E4B\u95F4\u7684\u6620\u5C04</strong></p><p>\u5982\u679C\u7EE7\u7EED\u6267\u884C<code>a[10000]=&#39;bbb&#39;</code>\uFF0C\u4E5F\u53EA\u4E0D\u8FC7\u662F\u53C8\u589E\u52A0\u4E86\u4E00\u6761<strong>\u4ECE10000\u5230&quot;bbb&quot;\u4E4B\u95F4\u7684\u6620\u5C04</strong>\u800C\u5DF2\u3002length\u81EA\u52A8\u53D8\u4E3A\u4E8610001\uFF0C\u8FD9\u7B26\u5408\u6211\u4EEC\u7684\u76F4\u89C9\u3002<strong>\u4E0D\u5B58\u5728\u6620\u5C04\u5173\u7CFB\uFF0C\u4F46\u53C8\u5904\u5728\u6570\u7EC4\u957F\u5EA6\u8303\u56F4\u5185\u7684\u6570\u7EC4\u9879\uFF0C\u5C31\u662F\u5B54</strong></p><p>\u6B64\u65F6\uFF0C\u8FD9\u4E2A\u6570\u7EC4\u4E0E\u957F\u5EA6\u4E3A2\u7684\u666E\u901A\u6570\u7EC4[&#39;aaa&#39;, &#39;bbb&#39;]\uFF0C\u5360\u7528\u76F8\u540C\u5927\u5C0F\u7684\u5185\u5B58\u7A7A\u95F4</p><h3 id="javascript\u6570\u7EC4\u7A00\u758F\u7279\u6027\u5E26\u6765\u7684\u201C\u602A\u5F02\u73B0\u8C61\u201D" tabindex="-1">JavaScript\u6570\u7EC4\u7A00\u758F\u7279\u6027\u5E26\u6765\u7684\u201C\u602A\u5F02\u73B0\u8C61\u201D <a class="header-anchor" href="#javascript\u6570\u7EC4\u7A00\u758F\u7279\u6027\u5E26\u6765\u7684\u201C\u602A\u5F02\u73B0\u8C61\u201D" aria-hidden="true">#</a></h3><h4 id="slice\u4F1A\u590D\u5236\u5B54" tabindex="-1">slice\u4F1A\u590D\u5236\u5B54 <a class="header-anchor" href="#slice\u4F1A\u590D\u5236\u5B54" aria-hidden="true">#</a></h4><div class="language-js"><pre><code><span class="line"><span style="color:#C792EA;">var</span><span style="color:#A6ACCD;"> arr </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> [ </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">a</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">b</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;"> ]</span></span>\n<span class="line"><span style="color:#676E95;font-style:italic;">// [&quot;a&quot;, undefined \xD7 1, &quot;b&quot;]</span></span>\n<span class="line"><span style="color:#A6ACCD;">arr</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">slice</span><span style="color:#A6ACCD;">(</span><span style="color:#F78C6C;">1</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">2</span><span style="color:#A6ACCD;">)</span></span>\n<span class="line"><span style="color:#676E95;font-style:italic;">// [undefined \xD7 1]</span></span>\n<span class="line"><span style="color:#A6ACCD;">arr</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">slice</span><span style="color:#A6ACCD;">()</span></span>\n<span class="line"><span style="color:#676E95;font-style:italic;">// [&quot;a&quot;, undefined \xD7 1, &quot;b&quot;]</span></span>\n<span class="line"></span></code></pre></div><h4 id="foreach\u3001every\u4F1A\u8DF3\u8FC7\u5B54\uFF08\u4E0D\u5BF9\u5B54\u8C03\u7528\u56DE\u8C03\u51FD\u6570\uFF09" tabindex="-1">forEach\u3001every\u4F1A\u8DF3\u8FC7\u5B54\uFF08\u4E0D\u5BF9\u5B54\u8C03\u7528\u56DE\u8C03\u51FD\u6570\uFF09 <a class="header-anchor" href="#foreach\u3001every\u4F1A\u8DF3\u8FC7\u5B54\uFF08\u4E0D\u5BF9\u5B54\u8C03\u7528\u56DE\u8C03\u51FD\u6570\uFF09" aria-hidden="true">#</a></h4><div class="language-js"><pre><code><span class="line"><span style="color:#C792EA;">var</span><span style="color:#A6ACCD;"> arr </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> [ </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">a</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">b</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;"> ]</span></span>\n<span class="line"><span style="color:#676E95;font-style:italic;">// [&quot;a&quot;, undefined \xD7 1, &quot;b&quot;]</span></span>\n<span class="line"><span style="color:#A6ACCD;">arr</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">forEach</span><span style="color:#A6ACCD;">(</span><span style="color:#C792EA;">function</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">(</span><span style="color:#A6ACCD;">x</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> i</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">console</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">log</span><span style="color:#F07178;">(</span><span style="color:#A6ACCD;">i</span><span style="color:#89DDFF;">+</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">.</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">+</span><span style="color:#A6ACCD;">x</span><span style="color:#F07178;">) </span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">)</span></span>\n<span class="line"><span style="color:#676E95;font-style:italic;">// 0.a</span></span>\n<span class="line"><span style="color:#676E95;font-style:italic;">// 2.b</span></span>\n<span class="line"><span style="color:#A6ACCD;">arr</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">every</span><span style="color:#A6ACCD;">(</span><span style="color:#C792EA;">function</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">(</span><span style="color:#A6ACCD;">x</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">x</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">length</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">===</span><span style="color:#F07178;"> </span><span style="color:#F78C6C;">1</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">)</span></span>\n<span class="line"><span style="color:#676E95;font-style:italic;">// true</span></span>\n<span class="line"></span></code></pre></div><h4 id="map\u4E0D\u5BF9\u5B54\u8C03\u7528\u56DE\u8C03\u51FD\u6570\uFF0C\u4F46\u662F\u5B54\u4F1A\u4FDD\u7559" tabindex="-1">map\u4E0D\u5BF9\u5B54\u8C03\u7528\u56DE\u8C03\u51FD\u6570\uFF0C\u4F46\u662F\u5B54\u4F1A\u4FDD\u7559 <a class="header-anchor" href="#map\u4E0D\u5BF9\u5B54\u8C03\u7528\u56DE\u8C03\u51FD\u6570\uFF0C\u4F46\u662F\u5B54\u4F1A\u4FDD\u7559" aria-hidden="true">#</a></h4><div class="language-js"><pre><code><span class="line"><span style="color:#A6ACCD;">arr</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">map</span><span style="color:#A6ACCD;">(</span><span style="color:#C792EA;">function</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">(</span><span style="color:#A6ACCD;">x</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;">i</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">i</span><span style="color:#89DDFF;">+</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">.</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">+</span><span style="color:#A6ACCD;">x</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">)</span></span>\n<span class="line"><span style="color:#676E95;font-style:italic;">// [ &#39;0.a&#39;, undefined \xD7 1, &#39;2.b&#39; ]</span></span>\n<span class="line"></span></code></pre></div><h4 id="filter\u4E0D\u5BF9\u5B54\u8C03\u7528\u56DE\u8C03\u51FD\u6570\uFF0C\u4F46\u662F\u5B54\u4F1A\u88AB\u8FC7\u6EE4\u6389" tabindex="-1">filter\u4E0D\u5BF9\u5B54\u8C03\u7528\u56DE\u8C03\u51FD\u6570\uFF0C\u4F46\u662F\u5B54\u4F1A\u88AB\u8FC7\u6EE4\u6389 <a class="header-anchor" href="#filter\u4E0D\u5BF9\u5B54\u8C03\u7528\u56DE\u8C03\u51FD\u6570\uFF0C\u4F46\u662F\u5B54\u4F1A\u88AB\u8FC7\u6EE4\u6389" aria-hidden="true">#</a></h4><div class="language-js"><pre><code><span class="line"><span style="color:#A6ACCD;">arr</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">filter</span><span style="color:#A6ACCD;">(</span><span style="color:#C792EA;">function</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">(</span><span style="color:#A6ACCD;">x</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#F07178;"> </span><span style="color:#FF9CAC;">true</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">)</span></span>\n<span class="line"><span style="color:#676E95;font-style:italic;">// [ &#39;a&#39;, &#39;b&#39; ]</span></span>\n<span class="line"></span></code></pre></div><h4 id="join\u4F1A\u5C06\u5B54\u8F6C\u5316\u4E3A\u4E00\u4E2A\u7A7A\u5B57\u7B26\u4E32\u8FDB\u884C\u62FC\u63A5\uFF0C\u4E0Eundefined\u4E00\u6837" tabindex="-1">join\u4F1A\u5C06\u5B54\u8F6C\u5316\u4E3A\u4E00\u4E2A\u7A7A\u5B57\u7B26\u4E32\u8FDB\u884C\u62FC\u63A5\uFF0C\u4E0Eundefined\u4E00\u6837 <a class="header-anchor" href="#join\u4F1A\u5C06\u5B54\u8F6C\u5316\u4E3A\u4E00\u4E2A\u7A7A\u5B57\u7B26\u4E32\u8FDB\u884C\u62FC\u63A5\uFF0C\u4E0Eundefined\u4E00\u6837" aria-hidden="true">#</a></h4><div class="language-js"><pre><code><span class="line"><span style="color:#A6ACCD;">arr</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">join</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">-</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;">)</span></span>\n<span class="line"><span style="color:#676E95;font-style:italic;">// &#39;a--b&#39;</span></span>\n<span class="line"><span style="color:#A6ACCD;">[ </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">a</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">undefined,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">b</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;"> ]</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">join</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">-</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;">)</span></span>\n<span class="line"><span style="color:#676E95;font-style:italic;">// &#39;a--b&#39;</span></span>\n<span class="line"></span></code></pre></div><p>\u800C\u5176\u4ED6\u6240\u6709\u7684\u6570\u7EC4\u65B9\u6CD5\u4F1A\u6B63\u5E38\u5BF9\u5F85\u5B54\uFF0C\u5C31\u50CF\u6570\u7EC4\u4E2D\u771F\u7684\u5B58\u5728\u8FD9\u4E2A\u201C\u7A7A\u4F4D\u201D\u4E00\u6837\uFF1A</p><div class="language-js"><pre><code><span class="line"><span style="color:#C792EA;">var</span><span style="color:#A6ACCD;"> arr2 </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> arr</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">slice</span><span style="color:#A6ACCD;">()</span></span>\n<span class="line"><span style="color:#A6ACCD;">arr2</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">sort</span><span style="color:#A6ACCD;">()</span></span>\n<span class="line"><span style="color:#676E95;font-style:italic;">// [ &#39;a&#39;, &#39;b&#39;, undefined \xD7 1 ]</span></span>\n<span class="line"></span></code></pre></div><h3 id="\u521D\u59CB\u5316\u65E0\u5B54\u6570\u7EC4\u7684\u65B9\u6CD5" tabindex="-1">\u521D\u59CB\u5316\u65E0\u5B54\u6570\u7EC4\u7684\u65B9\u6CD5 <a class="header-anchor" href="#\u521D\u59CB\u5316\u65E0\u5B54\u6570\u7EC4\u7684\u65B9\u6CD5" aria-hidden="true">#</a></h3><p>\u56E0\u4E3A\u6570\u7EC4\u4E2D\u7684\u5B54\u4F1A\u9020\u6210\u4E0A\u8FF0\u7684\u90A3\u4E9B\u201C\u602A\u5F02\u73B0\u8C61\u201D\uFF0C\u6240\u4EE5\u6211\u4EEC\u6709\u65F6\u5E0C\u671B\u521D\u59CB\u5316\u4E00\u4E2A\u6CA1\u6709\u5B54\u7684\u6570\u7EC4\u3002 \u6BD4\u5982\u6211\u4EEC\u5E0C\u671B\u521D\u59CB\u5316[0,1,2]\u8FD9\u6837\u7684\u6570\u7EC4\uFF0C\u4F46\u662F\u6211\u4EEC\u65E0\u6CD5\u901A\u8FC7new Array(3)\u4E0Emap\u65B9\u6CD5\u5F97\u5230\uFF1A</p><div class="language-js"><pre><code><span class="line"><span style="color:#C792EA;">var</span><span style="color:#A6ACCD;"> a1 </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">new</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Array</span><span style="color:#A6ACCD;">(</span><span style="color:#F78C6C;">3</span><span style="color:#A6ACCD;">)</span></span>\n<span class="line"><span style="color:#676E95;font-style:italic;">// [undefined \xD7 3]</span></span>\n<span class="line"><span style="color:#A6ACCD;">a1</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">map</span><span style="color:#A6ACCD;">(</span><span style="color:#C792EA;">function</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">(</span><span style="color:#A6ACCD;">x</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> i</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">i</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">)</span></span>\n<span class="line"><span style="color:#676E95;font-style:italic;">// [undefined \xD7 3]</span></span>\n<span class="line"><span style="color:#676E95;font-style:italic;">// \u56E0\u4E3Amap\u4F1A\u8DF3\u8FC7\u5B54\uFF0C\u6240\u4EE5\u5B9E\u9645\u4E0A\u56DE\u8C03\u51FD\u6570\u6CA1\u6709\u88AB\u8C03\u7528\u8FC7</span></span>\n<span class="line"></span></code></pre></div><p>\u6B63\u786E\u7684\u65B9\u6CD5\uFF1A</p><div class="language-js"><pre><code><span class="line"><span style="color:#C792EA;">var</span><span style="color:#A6ACCD;"> a2 </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Array</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">apply</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">null,</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Array</span><span style="color:#A6ACCD;">(</span><span style="color:#F78C6C;">3</span><span style="color:#A6ACCD;">))</span></span>\n<span class="line"><span style="color:#676E95;font-style:italic;">// [undefined, undefined, undefined]</span></span>\n<span class="line"><span style="color:#A6ACCD;">a2</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">map</span><span style="color:#A6ACCD;">(</span><span style="color:#C792EA;">function</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">(</span><span style="color:#A6ACCD;">x</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> i</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">i</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">)</span></span>\n<span class="line"><span style="color:#676E95;font-style:italic;">// [0, 1, 2]</span></span>\n<span class="line"><span style="color:#676E95;font-style:italic;">// map\u7684\u56DE\u8C03\u51FD\u6570\u6267\u884C\u4E863\u6B21</span></span>\n<span class="line"></span></code></pre></div><p>\u6253\u5370\u7ED3\u679C\u5206\u522B\u4E3A[undefined \xD7 3]\u548C[undefined, undefined, undefined]\uFF0Cchrome\u63A7\u5236\u53F0\u7528\u8FD9\u4E24\u79CD\u8868\u793A\u65B9\u5F0F\u6765\u533A\u5206\u5B54\u548C\u771F\u6B63\u7684undefined\u503C\uFF01</p><p>\u7B2C\u4E00\u79CD\u65B9\u6CD5\u6CA1\u6709\u6784\u9020\u51FA\u6620\u5C04\uFF0C\u53EA\u521B\u9020\u51FA\u4E863\u4E2A\u5B54\u3002\u800C\u7B2C\u4E8C\u79CD\u65B9\u6CD5\u521B\u5EFA\u51FA\u4E86\u771F\u6B63\u7684\u201C\u4ECE\u4E0B\u6807\u5230\u503C\u4E4B\u95F4\u7684\u6620\u5C04\u201D\uFF0C\u6620\u5C04\u7684\u503C\u4E3Aundefined\u3002\u56E0\u6B64map\u4E0D\u4F1A\u8DF3\u8FC7\u8FD9\u4E9B\u6570\u7EC4\u9879\u3002</p><h3 id="array-apply-null-array-n-\u7684\u539F\u7406" tabindex="-1">Array.apply(null, Array(n))\u7684\u539F\u7406 <a class="header-anchor" href="#array-apply-null-array-n-\u7684\u539F\u7406" aria-hidden="true">#</a></h3><p>\u4E3A\u4EC0\u4E48<code>var a2 = Array.apply(null, Array(3))</code>\u80FD\u521B\u9020\u51FA\u65E0\u5B54\u7684\u6570\u7EC4\u5462\uFF1F \u6211\u4EEC\u5C06\u4E00\u4E2A\u542B\u67093\u4E2A\u5B54\u7684\u6570\u7EC4\u4F5C\u4E3A\u7B2C\u4E8C\u4E2A\u53C2\u6570\u4F20\u9012\u7ED9apply\uFF0Capply\u5C06\u5229\u7528\u8FD9\u4E2A\u6570\u7EC4\u6765\u51B3\u5B9A\u8C03\u7528Array()\u7684\u53C2\u6570\u3002 \u56E0\u4E3A<strong>apply\u5C06\u6570\u7EC4\u4E2D\u7684\u5B54\u89C6\u4E3Aundefined</strong>\uFF0C\u6240\u4EE5Array\u8C03\u7528\u7684\u53C2\u6570\u5B9E\u9645\u4E0A\u4E3AArray(undefined, undefined, undefined)\u3002 \u53C8\u56E0\u4E3A\u901A\u8FC7Array(a,b,c)\u8FD9\u79CD\u65B9\u6CD5\u8C03\u7528Array\u4F1A\u8FD4\u56DE[a,b,c]\uFF0C\u6240\u4EE5Array(undefined, undefined, undefined)\u8FD4\u56DE\u7684\u662F[undefined, undefined, undefined]</p><p>\u9ED8\u8BA4\u663E\u793A\u6708</p><p>\u4E09,\u91CD\u8981\u68C0\u4FEE \u4E94\u516D\u7EA7\u98CE\u9669\u9884\u8B66 \u53BB\u6389\u4E94\u516D\u7EA7</p><p>\u52A0\u4E2A\u56FE\u7247</p>', 101);
  const _hoisted_102 = [
    _hoisted_1
  ];
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
    return openBlock(), createElementBlock("div", null, _hoisted_102);
  }
  var _11_Array = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
  export { __pageData, _11_Array as default };
  