What is the use of this?
Attempts to use eval() to assign value to variables or object properties fails.
Also new variables cannot be introduced using eval()Also variables and functions inside eval() are not created in the containing scope, they exist locally to the eval()
If you apply strict mode, some of the errors that would go unnoticed, will get attention.
Eg: object properties with duplicate names, attempt to assign values to undefined variables
In non-strict mode, any atempt to assign value to undefined variable will result in global variable getting created and assigned that value.
The strict mode is a new feature in ECMAScript 5.
Some assignments that fail silently, generates errors in strict mode.
Adding a property to non extensible object.
var myObj = new Object(); Object.preventExtensions(myObj); myObj.name = "Jamie";
In strict mode this results in error:
SCRIPT5046: Cannot create property for a non-extensible object
Similarly writing to a read-only property raises an error:
SCRIPT5045: Assignment to read-only properties is not allowed in strict mode
Inside a function if a is not defined and you say
a = 5;
it creates a global variable a
But in strict mode this leads to error:
Uncaught ReferenceError: a is not defined(…)
this of null or undefined are coerced to global in normal mode. In strict mode there is no such linking to global.