1.

Explain the benefits and drawbacks of using "use strict".

Answer»

In ECMAScript5, a new feature known as strict mode allows you to run a program or function within a strict operating context. Certain ACTIONS, therefore, cannot be taken due to this strict context, and more exceptions are THROWN. When the "use strict" statement is used, the browser is instructed to use "strict" mode, which is a more restricted and safer JavaScript feature set. You can specify "use strict" at the top of a function to evaluate the JS in strict mode. In strict mode, more errors are thrown and some features are disabled to make your code more robust, clear, and accurate.

Advantages:

  • Errors are thrown when some COMMON coding mistakes are detected.
  • By having strict mode, mistakes that make JavaScript engines tough to optimize can be fixed. Sometimes, strict mode code runs faster than similar, non-strict mode code.
  • Generally, it prevents or throws an error when an "unsafe" action is taken (for example, accessing the global object).
  • It disables poorly thought-out or confusing features.
  • Strict mode simplifies the PROCESS of writing "secure" JavaScript.

Disadvantages:

  • Many of the functions that most developers use are absent.
  • It is not possible to access function.caller or function.arguments anymore.
  • If you concatenate scripts written in different strict modes, you may encounter problems.


Discussion

No Comment Found