Congratulations to all the winners of April 2013, they have won INR 3400 cash and INR 20147 worth prizes !
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 9888 |  Welcome, Guest!   Register  Login
 Home > Interview Questions > JavaScript Interview Questions > Difference between undefined and undecla ...

Difference between undefined and undeclared variables.

Interview question and answer by: Ddd | Posted on: 2/21/2011 | Category: JavaScript Interview questions | Views: 3236 | | Points: 40


Answer:

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 variable
var a;
alert(a);
//b is undeclared variable
alert("hello"+"--"+b);
</script>

a:undefined:

b:will also be undefined but that error message can be seen by clicking in browser
status bar: if some value is assigned to b, then it will be displayed in the output

Asked In: Many Interviews | Alert Moderator 
Found interesting? Add this to:


>> Write Response - Respond to this post and get points

Even more ... | Submit Interview Questions and win prizes!

More Interview Questions from Ddd

Even more ... | Submit Interview Questions and win prizes!


About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/19/2013 10:35:12 AM