Function.prototype.arguments - JavaScript | MDN 跳转到主要内容 跳转到搜索 MDN HTML HTML: Markup language HTML reference Elements Global attributes Attributes See all… HTML guides Responsive images HTML cheatsheet Date & time formats See all… Markup languages SVG MathML XML CSS CSS: Styling language CSS reference Properties Selectors At-rules Values See all… CSS guides Box model Animations Flexbox Colors See all… Layout cookbook Column layouts Centering an element Card component See all… JavaScriptJS JavaScript: Scripting language JS reference Standard built-in objects Expressions & operators Statements & declarations Functions See all… JS guides Control flow & error handing Loops and iteration Working with objects Using classes See all… Web APIs Web APIs: Programming interfaces Web API reference File system API Fetch API Geolocation API HTML DOM API Push API Service worker API See all… Web API guides Using the Web animation API Using the Fetch API Working with the History API Using the Web speech API Using web workers All All web technology Technologies Accessibility HTTP URI Web extensions WebAssembly WebDriver See all… Topics Media Performance Privacy Security Progressive web apps Learn Learn web development Frontend developer course Getting started modules Core modules MDN Curriculum Check out the video course from Scrimba, our partner Learn HTML Structuring content with HTML module Learn CSS CSS styling basics module CSS layout module Learn JavaScript Dynamic scripting with JavaScript module Tools Discover our tools Playground HTTP Observatory Border-image generator Border-radius generator Box-shadow generator Color format converter Color mixer Shape generator About Get to know MDN better About MDN Advertise with us Community MDN on GitHub Blog 切换侧边栏 面向开发者的 Web 技术 JavaScript JavaScript 参考 JavaScript 标准内置对象 Function Function.prototype.arguments 主题 跟随系统 浅色 深色 中文 (简体) 记住语言 了解更多 Deutsch English (US) Español Français 日本語 한국어 Português (do Brasil) Русский 中文 (简体) 此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。 View in English Always switch to English Function.prototype.arguments 已弃用: 不再推荐使用该特性。虽然一些浏览器仍然支持它,但也许已从相关的 web 标准中移除,也许正准备移除或出于兼容性而保留。请尽量不要使用该特性,并更新现有的代码;参见本页面底部的兼容性表格以指导你作出决定。请注意,该特性随时可能无法正常工作。 非标准: 该特性尚未标准化。我们不建议在生产环境中使用非标准特性,因为它们在浏览器中的支持有限,且可能发生变化或被移除。不过,在没有标准选项的特定情况下,它们可以作为合适的替代方案。 备注:Function 对象的 arguments 属性已被弃用。访问 arguments 对象的推荐方式是在函数内部引用可用的 arguments 变量。 Function 实例的 arguments 访问器属性返回传递给该函数的参数。对于严格模式、箭头函数、异步函数和生成器函数,访问 arguments 属性会抛出 TypeError。 本文内容 描述 示例 规范 浏览器兼容性 参见 描述 arguments 的值是一个类数组对象,对应于传入函数的参数。 在递归的情况下,即如果函数 f 在调用栈上出现多次,f.arguments 的值表示最近一次调用该函数时的参数。 如果函数没有正在进行的、未完成的调用(即函数已被调用但尚未返回),arguments 属性的值通常为 null。 请注意,ECMAScript 规范只规定了 Function.prototype 具有一个初始的 arguments 访问器,对于任何 get 或 set 请求都无条件地抛出 TypeError(称为“毒丸访问器”),而且引擎实现不允许改变此语义,除非是非严格的普通函数。(对于非严格的普通函数)arguments 属性的实际行为如果不是抛出错误,则该行为由实现定义。例如,Chrome 将其定义为自有的数据属性,而 Firefox 和 Safari 扩展了初始的毒丸访问器 Function.prototype.arguments,以特殊处理非严格函数的 this 值。 js (function f() { if (Object.hasOwn(f, "arguments")) { console.log( "arguments 是带有描述符的自有属性", Object.getOwnPropertyDescriptor(f, "arguments"), ); } else { console.log( "f 没有自有的名为 arguments 的属性。尝试获取 f.[[Prototype]].arguments", ); console.log( Object.getOwnPropertyDescriptor( Object.getPrototypeOf(f), "arguments", ).get.call(f), ); } })(); // 在 Chrome 中: // arguments 是带有描述符的自有属性 {value: Arguments(0), writable: false, enumerable: false, configurable: false} // 在 Firefox 中: // f 没有自有的名为 arguments 的属性。尝试获取 f.[[Prototype]].arguments // Arguments { … } 示例 使用 arguments 属性 js function f(n) { g(n - 1); } function g(n) { console.log(`之前:${g.arguments[0]}`); if (n > 0) { f(n); } console.log(`之后:${g.arguments[0]}`); } f(2); console.log(`返回:${g.arguments}`); // 输出: // 之前:1 // 之前:0 // 之后:0 // 之后:1 // 返回:null 规范 不属于任何规范。 浏览器兼容性 启用 JavaScript 以查看此浏览器兼容性表。 参见 arguments 函数 帮助改进 MDN 此页面对您有帮助吗? 是 否 了解如何参与贡献 此页面最后更新于 2026年5月26日,由 MDN 贡献者更新。 在 GitHub 上查看此页面 • 报告此内容的问题 筛选侧边栏 清除筛选输入 JavaScript 标准内置对象 Function 构造函数 Function() 实例方法 Function.prototype.apply() Function.prototype.bind() Function.prototype.call() Function.prototype.toString() Function.prototype[Symbol.hasInstance]() 实例属性 Function.displayName Function:length Function.name Function.prototype.prototype Function.prototype.arguments Function.prototype.caller 继承 Object/Function 静态方法 Function.prototype.apply() Function.prototype.bind() Function.prototype.call() Function.prototype.toString() Function.prototype[Symbol.hasInstance]() 静态属性 Function.displayName Function:length Function.name Function.prototype.prototype Function.prototype.arguments Function.prototype.caller 实例方法 Object.prototype.__defineGetter__() Object.prototype.__defineSetter__() Object.prototype.__lookupGetter__() Object.prototype.__lookupSetter__() Object.prototype.hasOwnProperty() Object.prototype.isPrototypeOf() Object.prototype.propertyIsEnumerable() Object.prototype.toLocaleString() Object.prototype.toString() Object.prototype.valueOf() 实例属性 Object.prototype.__proto__ Object.prototype.constructor MDN 构建更美好互联网的蓝图。 MDN 关于 博客 Mozilla 招聘 与我们合作投放广告 MDN Plus 产品帮助 参与贡献 MDN 社区 社区资源 写作指南 MDN Discord MDN GitHub 主页 开发者 Web 技术 学习 Web 开发 指南 教程 术语表 Hacks 博客 Mozilla 网站隐私声明 遥测设置 法律声明 社区参与准则 本内容的部分版权归 mozilla.org 贡献者所有,©1998–2026。内容依据知识共享许可协议提供。