What is the significance and benefit of including 'use strict' at the beginning of a JavaScript source file?
The "use strict" is not a statement, rather a literal expression that is vital to your code as it presents a way for voluntarily enforcing a stricter parsing and error handling process on your JavaScript code files or functions during runtime. Most importantly, it just makes your code very easy to manage.
Here are some of the benefits of using use strict expression at the beginning of a JS source file:
- It makes debugging a lot easier by making the code errors that are ignored generate an error or throw exceptions.
- It prevents the most common error of making an undeclared variable as a global variable if it is assigned a value.
- It does not allow the usage of duplicate property names or parameter values.
BY Best Interview Question ON 20 Jun 2020