Home > Blockchain >  I'm trying to check that var in javaScript can hold reserve words, this error appears
I'm trying to check that var in javaScript can hold reserve words, this error appears

Time:02-03

let undefined = 'koko';

console.log(undefined);

and for that i have this error : Uncaught SyntaxError: Identifier 'undefined' has already been declared (at app.js:1:1).

Knowing that first line of script was a comment.

Anyone can Explain this to me?

CodePudding user response:

undefined is a global property represents the primitive value undefined.
It is one of JavaScript's primitive types.

When you try to redeclare any existing variable (in this case already declared by JS itself)
you will get a redecleration error.

CodePudding user response:

undefined is a reserved word, you can't redefine it

  • Related