Adding "use strict" to the JS code is equivalent to entering strict mode, and strict mode changes the syntax and runtime behavior to turn hidden problems into errors.
The strict mode of JS has the following features:
First, variable declaration
Global variables must be declared before they can be used, and if not declared with Var, they will be used without error.
Second, function declaration
You cannot declare a function within a block of code that is not a function, such as an if statement, a loop statement.
Third, static binding
In the compilation phase, you determine which object the property and method belong to.
1. Prohibit use with statement
Because the WITH statement cannot be determined at compile time, the property exactly belongs to which object.
2. Eval scope
In normal mode, only the global and function scopes, in strict mode, will have the eval scope.
Four, this
When using a constructor, if you do not use New,this to point to the window, you will get an error.
Five, delete
Cannot delete a variable, only an object property with configurable set to True can be deleted.
Deleting a read-only property will cause an error.
Six, can not duplicate the name
Object properties cannot have duplicate names, and function parameters cannot have duplicate names.
The strict mode and normal mode of JavaScript