What does this line below do?
undefined = \'A value\';
If it does not change the value of undefined then what happens behind t
Unlike things like true, 123 or null, undefined is not a literal. That means using the undefined identifier is not a foolproof way to obtain the undefined value. Instead, can use the void operator, e.g. void 0.
By default, undefined defined a property of the global object, that is, global variable. Before ECMAScript 5, that property was writable, so
undefined = "A value";
replaced the value of window.undefined, assuming it was not shadowed by a local variable. Then if you used "A value" === undefined, you would get true. And void 0 === undefined would produce false.
ECMAScript 5 changed this behavior, and now the property is not writable nor configurable. Therefore, assignments to undefined will be ignored in non-strict mode, and will throw an exception is strict mode. Under the hood,
undefined = "A value"; is a Simple Assignment"A value" in a reference with base the global object, referenced name "undefined", and strict flag if the assignment is made in strict mode."undefined" as the property name, "A value" as the value, and the strict flag as the throw flag."undefined", the property descriptor {[[Value]]: "A value"}, and the throw flag as arguments.However, you are still able to declare local undefined variables:
(function() {
var undefined = "A value";
alert(undefined); // "A value";
})();