Well, clarity and speed.
Unlike what the popular answers and question in SO say - the real primary goal of strict mode and the "use strict"
directive is to eliminate dynamic scoping in JavaScript which is why changing arguments via arguments
and changing arguments
itself is not allowed, why with
is not allowed, and so on.
Clarity
Strict mode does not allow dynamic scoping, so you can always statically know what a variable refers to. with
statements, changing variables via arguments and other types of non-static scoping make code less readable, in non strict mode:
// example from referenced thread
// global code
this.foo = 1;
(function () {
eval('var foo = 2');
with ({ foo: 3 }) {
foo // => 3
delete foo;
foo // => 2
delete foo;
foo // => 1
delete foo;
foo // ReferenceError
}
}());
This sort of headache is avoided in strict mode.
Speed
Strict mode is much faster than non strict mode. A lot of optimizations can only be made in strict mode since it can assume a lot more about what doesn't change and how to resolve references. V8 internally uses this extensively.
References: