+ 2
Is "" as same as null in javascript?
I found this codes from a book. I can't understand why they use &&(and) because I don't know that second statement (name!="") is true or false? if (name!=null && name!=""){ alert("blah blah blah.."); } else{ alert("blah blah blah blah..."); }
4 Respuestas
+ 2
null and "" are different.
null means that the variable is not initialized yet. According to the above case it make sures that the name is initialized and it is not blank - some funny users like to remain their name blank😂.So that case would be very useful 😆
+ 4
No, they are not the same.
That condition is to make sure the variable 'name' is not null and also not empty string.
+ 1
Lord Krishna Thanks
+ 1
Seniru Pasan 👍👍