A short and simple answer would be: "because it makes your code much easier to debug!"


Without using strict mode:

  x = 1;

That would declare your variable in the global namespace.

With using namespace it would throw an error such as 'x is not defined'. So the strict mode forces you to declare your variables correctly.

The strict mode can be used globally or within a specific scope in your functions:

  a = 3; // no strict mode

function x() {
  "use strict";

  b = 4; // throws error because strict mode


1,883 0 14