Expert Developer JavaScript Question: Download Expert JavaScript Developer PDF

What is difference between undefined variable and undeclared variable?

Tweet Share WhatsApp

Answer:

► The variable which are declared in the program but not assigned any value yet is called undefined variable while the variable which are not declared in the program is called undeclared variable.
► For Example :
undeclared variable:
<script>
var p;
alert(p); // This will give error because p is undeclared variable.
</script>
? undefined variable
<script>
alert(p); //This will give error because p is undefined.
</script>

Download Expert JavaScript Developer PDF Read All 150 Expert JavaScript Developer Questions
Previous QuestionNext Question
How can I set up my own JavaScript error handler?What is escape() function?