Undefined Const Variable


#1

Why does having a const variable undefined result in an error?

const notDefined;
console.log(notDefined);
const valueless;
console.log(valueless);

#2

A lot of text that you can type isn’t valid javascript, I don’t see how this is special so I wouldn’t say there’s an answer to “why”
Perhaps you might instead argue for why it would be valid or useful, especially if there’s an expectation that you would be able to do it, where does that come from? If there’s nothing to indicate that it should do something, then it’s not so strange if it doesn’t.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.