Reputation: 30
I tried to execute following lines of code on Nodejs and chrome browser. In nodejs, it executed successfully But on chrome browser, it throws an error.
const undefined = 1;
console.log(undefined);
// Nodejs: prints 1
//chrome browser: VM359:1 Uncaught SyntaxError: Identifier 'undefined' has already been declared
If undefined is already declared as a value, don't you guys think undefined
is behaving a variable in nodejs ?
Upvotes: 0
Views: 44
Reputation: 2709
You can not override undefined according to https://stackoverflow.com/a/7173833/1331578 . It might work on node where no global object will be used. But in general it is just not writable name.
Upvotes: 1