Each variable holds the value undefined till the program reaches the line where we have assigned that variable. After that line, the variable’s undefined value gets replaced by the original value.
Output (In console):
- If you are assigning a function call to a variable, and that function doesn’t return anything, the variable will become undefined.
- You can explicitly assign undefined to any variable but it is not good practice to use language keywords in the way it is not expected.
Difference between undefined and not defined
|It works like when we declared a variable in the code but did not assign the value before printing the variable value||It works like when we did not declare the variable and try to call that variable.|
Please Login to comment...