--- title: Function.arguments slug: Web/JavaScript/Reference/Global_Objects/Function/arguments translation_of: Web/JavaScript/Reference/Global_Objects/Function/arguments --- <div>{{JSRef}} {{deprecated_header}}</div> <p><code>function.arguments</code> 属性代表传入函数的实参,它是一个类数组对象。</p> <h2 id="描述">描述</h2> <p><code><em>function</em>.arguments</code> 已经被废弃了, 现在推荐的做法是使用函数内部可用的 {{jsxref("Functions/arguments", "arguments")}} 对象来访问函数的实参。</p> <p>在函数递归调用的时候(在某一刻同一个函数运行了多次,也就是有多套实参),那么 <code>arguments</code> 属性的值是最近一次该函数调用时传入的实参,下面的示例有演示。</p> <p>如果函数不在执行期间,那么该函数的 <code>arguments</code> 属性的值是 <code>null</code>。</p> <h2 id="示例">示例</h2> <pre class="brush: js">function f(n) { g(n - 1); } function g(n) { console.log('before: ' + g.arguments[0]); if (n > 0) { f(n); } console.log('after: ' + g.arguments[0]); } f(2); console.log('函数退出后的 arguments 属性值:' + g.arguments); // 输出: // before: 1 // before: 0 // after: 0 // after: 1 // 函数退出后的 arguments 属性值:null </pre> <h2 id="规范">规范</h2> <table class="standard-table"> <tbody> <tr> <th scope="col">规范名称</th> <th scope="col">规范状态</th> <th scope="col">备注</th> </tr> <tr> <td>{{SpecName('ES1')}}</td> <td>{{Spec2('ES1')}}</td> <td>arguments 属性首次实现于 JavaScript 1.0,首次添加进规范是在 ES1,在 ES3 中被删除。</td> </tr> <tr> <td>{{SpecName('ES5.1', '#sec-10.6', 'arguments object')}}</td> <td>{{Spec2('ES5.1')}}</td> <td>{{jsxref("Functions/arguments", "arguments")}}</td> </tr> <tr> <td>{{SpecName('ES6', '#sec-arguments-object', 'arguments object')}}</td> <td>{{Spec2('ES6')}}</td> <td>{{jsxref("Functions/arguments", "arguments")}}</td> </tr> </tbody> </table> <h2 id="浏览器兼容性">浏览器兼容性</h2> {{Compat}} <h2 id="相关链接">相关链接</h2> <ul> <li>{{jsxref("Functions/arguments", "arguments")}}</li> <li>{{jsxref("Functions", "函数和函数的作用域", "", 1)}}</li> </ul>