Why we should use ‘use strict’ in JavaScript?
The use of ‘use strict’ is a good way to enforce stricter parsing and error handling on JavaScript code at runtime. Because of stricter parsing, code errors that would have been ignored or would fail silently will produce errors.
Debugging becomes easier
The stricter parsing generates errors beforehand instead of failing silently. This helps the developer detects or debugs the code error easier.
Protect accidental globals
Without strict mode, assigning a value to an undeclared variable automatically creates a global variable with that name. In strict mode, attempting to do so throws an error.
Remove this coercion
Without strict mode, a reference to this value of null or undefined is automatically coerced to the global. In strict mode, referencing this value of null or undefined throws an error.
eval() becomes safer
In strict mode and in non-strict mode there are some differences in the way eval() behaves. In strict mode, variables and functions declared inside of an eval() statement are not created in the containing scope.
Invalid usage of delete.
The delete operator cannot be used on non-configurable properties of the object. Non-strict code will fail silently when an attempt is made to delete a non-configurable property, whereas strict mode will throw an error in such a case.