If I have a declaration as follows:
var j;
does j==null until I set it equal to something?
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.
No, it has the default value of
undefinedBut if want to use the
!jcondition, it will work with both the values (i.e. undefined or null)Note that
(j==null)istrue, but(j===null)isfalse… JavaScript have “falsy” values and sometimes unexpected rules to convert values, plus fancy===operator to compare value and type at the same time.