Strict mode
suggest changeSyntax
- ‘use strict’;
- “use strict”;
use strict
;
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
with
statement is unsupported; eval
cannot create variables in the surrounding scope;- Functions’
.caller
and.arguments
properties are unsupported; - A function’s parameter list cannot have duplicates;
window
is no longer automatically used as the value ofthis
.
NOTE:- ‘strict’ mode is NOT enabled by default as if a page uses JavaScript which depends on features of non - strict mode, then that code will break. Thus, it has to be turned on by the programmer himself / herself.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents