- Variable declarations: In strict mode, all variables must be declared with a var, let, or const keyword. This helps prevent issues with undeclared variables and variable hoisting.
- No implicit globals: In strict mode, undeclared variables are not automatically created as global variables. This helps prevent unintentional global variable creation.
- More restrictive function calls: In strict mode, the “this” keyword inside a function will not refer to the global object, as it would in non-strict mode. Additionally, strict mode requires that functions be called with the correct number of arguments.
- Eliminating some silent errors: In strict mode, certain types of errors that would have been ignored or handled silently in non-strict mode will instead throw an error. This can help developers catch potential issues earlier.
- More secure: Strict mode helps prevent certain types of code injection attacks by disallowing the use of the “eval” function to execute arbitrary code.