- Variables declared using
varkeyword must be initialized before use
- It makes
thiskeyword behave differently in certain situations
- It prohibits the use of certain unadvisable and/or deprecated syntax
x = 5; // this will cause an error, because x is not declared
It is highly recommended to use strict mode, as it makes your code more robust by eliminating some silent errors and can help you identify bugs early in development. It’s also a good way to make sure that your code is not relying on old, deprecated features of the language.
It’s worth noting that strict mode only applies to the code in which it is used. It does not affect the code in any other scripts or in any code that is executed after the current script.