Reading You-dont-know-Js at this chapter: https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/ch3.md
there's a code snippet:
undefined = true; // setting a land-mine for other code! avoid!
(function IIFE( undefined ){
var a;
if (a === undefined) {
console.log( "Undefined is safe here!" );
}
})();
as for the immediately executed function, I know that the argument is undefined, a is also undefined, thus a===undefined.
my question is that, how is it possible to assign a value to undefined? As I understand, undefined is a primitive type in js, then what is the meaning of undefined = true;?
Additionally, to test my understanding, I changed this code a little:
undefined = 5; // set undefined to an integer? how can it be?
(function IIFE( undefined ){
var a;
if (a === undefined) {
console.log( "Undefined is safe here!" );
}
})(undefined); //still execute console.log function
and the result remains same