JavaScript strict mode advantages. Why is it there?

Just a few examples why JavaScript strict model is great. Just great.

function f() {

 "use strict"; // Use ECMAScript 5 strict mode in browsers that support it

 var xfoo;

 xFoo = 1; 


There will be an error : assigning to an undeclared variable, since inside the function f you cannot use undeclared variables.

"use strict"; function f(eval) {}

You cannot have eval as variable name. Actually you can but not in a strict mode. This is why strict mode is so nice.


tags: & category: -