Strict mode
suggest changeSyntax
'use strict';"use strict";
The directive is a string-literal statement at the start of a script or function, before other statements. A template literal does not enable strict mode.
Remarks
Strict mode is an option added in ECMAScript 5 to enable a few backwards-incompatible enhancements. Behaviour changes in “strict mode” code include:
- Assigning to undefined variables raises an error instead of defining new global variables;
- Assigning to or deleting non-writable properties (such as
window.undefined) raises an error instead of executing silently; - Legacy octal syntax (ex.
0777) is unsupported; - The
withstatement is unsupported; evalcannot create variables in the surrounding scope;- Functions’
.callerand.argumentsproperties are unsupported; - A function’s parameter list cannot have duplicates;
- In a plain function call,
thisisundefinedinstead of the global object.
Strict mode is not the default for a classic script. Modules and class bodies are strict. Code that depends on sloppy-mode behavior breaks if the directive is added, so turn it on deliberately.
Function scoping in strict mode
Behaviour of a functions arguments list
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents