What are the differences between undeclared and undefined variables?

Posted by Jessica Taylor | Updated on

Below are the major differences between undeclared and undefined variables,

undeclaredundefined
These variables do not exist in a program and are not declaredThese variables declared in the program but have not assigned any value
If you try to read the value of an undeclared variable, then a runtime error is encounteredIf you try to read the value of an undefined variable, an undefined value is returned.

If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers