Javascript

Topic: JS Data Types

Difference between undefined and undeclared variables.

undefined variables are those that are not assigned any value but declared in the program.if we try to read the value, an error message "undefined" is displayed.undeclared variables are those that are not declared in the program .if we try to read their values gives runtime error.But if undeclared variables are assigned some value then implicit declaration is done .example:<script>//a is undefined variablevar a;alert(a);//b is undeclared variablealert("hello"+"--"+b);</script>a:undefined:b:will also be undefined but that error message can be seen by clicking in browserstatus bar: if some value is assigned to b, then it will be displayed in the output

Browse random answers: