I have a simple if statement
if(variable == null)
does not enter the statement
if(variable == "")
does
Why does this happen??
What is the difference between “” and null in javascript
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.
""is the empty string. In other words, it’s a string of length 0.nullon the other hand is more like a generic placeholder object (or an object representing the absence of an object). There’s alsoundefinedwhich is different from both""andnull.But the point is,
"" != nullso therefore: