Undefined vs. undeclared variables

Undefined vs. undeclared variables

It's important to distinguish between undefined and undeclared variables. Also, to is the one of most asked questions in the interview.

For Example

let message;
console.log(message) // undefined

Undefined variables are those variables which is been not initialized with a value. In the above example, we can see that the message a variable has been declared and console logged but the message has not been initialized.

Whereas, Undeclared variables are those variables which are been called without declaring a variable.

console.log(area) // Reference Error: area is not defined