text: "use strict";(self.webpackChunkvuepress_blog=self.webpackChunkvuepress_blog||[]).push([[1260],{49575:(n,s,a)=>{a.r(s),a.d(s,{data:()=>p});const p={key:"v-c9c55b22",path:"/typora/01frontEnd/02JavaScript/014arguments.html",title:"14 函数arguments",lang:"zh-CN",frontmatter:{},excerpt:"",headers:[],filePathRelative:"typora/01frontEnd/02JavaScript/014arguments.md",git:{updatedTime:1631527134e3}}},68719:(n,s,a)=>{a.r(s),a.d(s,{default:()=>t});const p=(0,a(36425).uE)('<h1 id="_14-函数arguments" tabindex="-1"><a class="header-anchor" href="#_14-函数arguments" aria-hidden="true">#</a> 14 函数arguments</h1><ol><li><p>因为<code>console.log()</code>也是通过<code>()</code>来调用的，所以log也是一个函数</p></li><li><p>log函数的特点</p><ol><li><p>无论传入多少参数都能接收</p><div class="language-text ext-text line-numbers-mode"><pre class="language-text"><code>console.log(1);//1\nconsole.log(1, 2);//1 2\n</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div></li></ol></li><li><p>为什么log函数可以接收多个参数</p><p>内部实现原理用到了arguments。</p></li><li><p>arguments的作用：</p><p>保存所有传递给函数的实参。</p><div class="language-javascript ext-js line-numbers-mode"><pre class="language-javascript"><code><span class="token keyword">function</span> <span class="token function">getSum</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>\n\t<span class="token comment">//每个函数中都有一个叫做arguments的东东</span>\n\t<span class="token comment">//arguments其实是一个伪数组</span>\n\tconsole<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>arguments<span class="token punctuation">)</span><span class="token punctuation">;</span>\n\tconsole<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>arguments<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n\tconsole<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>arguments<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n<span class="token punctuation">}</span>\n\n<span class="token function">getSum</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div></li></ol>',2),t={render:function(n,s){return p}}}}]);