Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

SyntaxError: 'arguments'/'eval' can't be defined or assigned to in strict mode code

The JavaScriptstrict 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 abinding calledarguments oreval, 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)

Error type

What went wrong?

In strict mode, the namesarguments andeval behave as if they arereserved words: you cannot make they refer to anything other than thearguments object in functions or the globaleval function.

Examples

Invalid cases

js
"use strict";const arguments = [1, 2, 3];console.log(Math.max(...arguments));function foo(...arguments) {  console.log(arguments);}

Valid cases

js
"use strict";const args = [1, 2, 3];console.log(Math.max(...args));function foo(...args) {  console.log(args);}

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp