I made a small POC with and without strict mode .
The effect is that if you do not use strict mode , everything will be fine. If you use strict mode , you will be pleased:
TypeError: cannot assign read-only property to 'undefined'
Now go to POC:
"use strict" var c; if (c === undefined) { console.log("nothing happened") } undefined = "goofy" c = "goofy" if (c === undefined) { console.log("c is 'goofy' and it equal to undefined.. gosh.. we broke js") }
Now, as I said, in strict mode you get a TypeError , and when you remove "use strict" script goes fine, and the output is just nothing happened .
I found this Q / A , which may be useful if you want to know more.
NOTE. I tested this code with Node.js
FredMaggiowski Apr 09 '16 at 17:05 2016-04-09 17:05
source share