How can we differentiate between var foo; and var foo=undefined;?
typeof foo will return for both “undefined” and foo in window will return for both true;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
var fooimpliesvar foo=undefined, unless of courseundefinedis set to something other thanundefined.This can be seen in the Browser Console, if you initialise a variable but don’t give it a value, it will have the value
undefined(and the type"undefined")