eval AND ARGUMENTS
Strict mode now explicitly disallows using eval
and arguments
as identifiers and manipulating their values. For example:
// Redefining eval and arguments as variables
// Non-strict mode: Okay, no error.
// Strict-mode: Throws syntax error
let eval = 10;
let arguments = "Hello world!";
In nonstrict mode, you can overwrite eval
and assign arguments
to a value. In strict mode, this causes a syntax error. You can't use either as an identifier, which means all of the following use cases throw a syntax error:
- Declaration using
let
- Assignment to another value
- Attempts to change the contained value, such as using
++
- Used as function names
- Used as named function arguments
- Used as exception name in
try-catch
statement