What are Differences between undefined and not defined in javascript?
Answers (2)
Add Answer- error as undefined :
It works like when we declared a variable in the code but did not assign the value before printing the variable value.
Example:
let name; console.log(name); //undefined
- error as not defined:
It works like when we did not declare the variable and try to call that variable.
Example :
<script> console.log(a); var a = 5; console.log(a); console.log(b); </script> // refference error (b) is not defined.