语法错误:在严格模式代码中无法定义或分配 'arguments'/'eval'
当尝试创建名为 arguments
或 eval
的 binding 或分配给此类名称时,会发生 JavaScript 严格模式 特有的异常 "在严格模式代码中无法定义或分配 'arguments'" 或 "在严格模式代码中无法定义或分配 'eval'"。
¥The JavaScript strict mode-only exception "'arguments' can't be defined or assigned to in strict mode code" or "'eval' can't be defined or assigned to in strict mode code" occurs when attempting to create a binding called arguments
or eval
, or assign to such a name.
信息
¥Message
SyntaxError: Unexpected eval or arguments in strict mode (V8-based) SyntaxError: 'arguments' can't be defined or assigned to in strict mode code (Firefox) SyntaxError: Cannot modify 'arguments' in strict mode. (Safari) SyntaxError: Cannot destructure to a parameter name 'arguments' in strict mode. (Safari) SyntaxError: Cannot declare a variable named arguments in strict mode. (Safari) SyntaxError: Cannot declare a catch variable named 'arguments' in strict mode. (Safari) SyntaxError: 'arguments' is not a valid function name in strict mode. (Safari)
错误类型
什么地方出了错?
¥What went wrong?
在严格模式下,名称 arguments
和 eval
的行为就像它们是 保留字 一样:你不能让它们引用函数中的 arguments
对象或全局 eval
函数以外的任何东西。
¥In strict mode, the names arguments
and eval
behave as if they are reserved words: you cannot make they refer to anything other than the arguments
object in functions or the global eval
function.