The "use strict"
directive was new in ECMAScript version 5.
It is not a statement, but a literal expression, ignored by earlier versions of JavaScript.
The purpose of "use strict"
is to indicate that the code should be executed in "strict mode".
With strict mode, you can not, for example, use undeclared variables.
All modern browsers support "use strict" except Internet Explorer 9 and lower:
The numbers in the table specify the first browser version that fully supports the directive.
You can use strict mode in all your programs. It helps you to write cleaner code, like preventing you from using undeclared variables.
"use strict"
is just a string, so IE 9 will not throw an error even if it does not understand it.
Practice Excercise Practice now