Strict Mode or “use strict” is a new feature introduced in ECMAScript 5 that allows you to place a program, function or variable in a strict operating context or environment. This strict context or environment restricts more actions from being taken accidentally by developers and it issues various exceptions which are thrown when certain conditions are not fulfilled.
- It helps in catching various coding wrong practices and errors by throwing some kinds of exceptions.
- It prevents access to the global object by throwing errors so that no unwanted access is gained by stranger.
- You can apply strict mode to a single section of code i.e. function or you can apply it to the whole file.
HOW TO USE IT?
In order to use it in your program just type the keyword “use strict” at the top and then write your code at the bottom. All the code below the keyword will be interpreted according to the rules and it will be strict.
WHEN TO USE IT?
A programmer scientist by the mind and a passionate blogger by heart ❤️. Fountainhead of Coding Shiksha Life motto: Live while you can! Teach & inspire while you could & Smile while you have the teeth.Gautam Sharma