What is Undefined?
In JavaScript, Undefined means that a variable has been declared but not assigned a value. In other words, the system recognizes its existence but doesn't know its value
var myVar;
console.log(myVar); // Output: Undefined
//In the example above, myVar is declared but not
// assigned any value. Hence, it is Undefined.
Undefined is not an error, but rather a specific type of value that JavaScript uses to tell you there's no value."
What is Not Defined?
Not Defined means that a variable has not been declared at all. The system doesn't recognize the variable's existence.
console.log(myVar); // Output: myVar is not defined
"Not Defined is an error you get when you try to use a variable that doesn't exist at all."
Undefined | Not Defined |
Variable is declared but not assigned a value | Variable is not declared at all |
System recognizes the variable | system doesn't recognize the variable |
Not an error, but a type of value | An error occoured when trying to use a non-existent variable |
|
|
|
|
|