Have you ever noticed use of strict keyboard as shown in following image anywhere?
You can put strict mode restriction
- On the function level
- On the page level
You can put strict restriction on function level as following
Now let us try to put some code in above function. In below code we are assigning value to a variable which is not declared. We have also put function is the strict mode.
If you have put strict mode then you will get error if you try to perform following operations.
- Assigning value to non-declared variable
- Assigning value to read only variable
- Defining duplicate property
- Defining duplicate parameters in a function
- Using future reserved keywords like interface, let, package etc.
- Cannot defined a function inside if-else or for statement
There are many other operations will give you error in strict mode. I hope now purpose of strict mode is clear to you. Thanks for reading!Follow @debug_mode