Lee
Member since Mar 22, 2010
- Profile: /members/5700-lee.htm
- Comments: 2
Recent Blog Comments By Lee
-
Javascript's Implicit Boolean Conversions
Posted on May 18, 2010 at 5:09 PM
@Han I fully agree with using the || (or ?? in C#) null coalesce operator and I do use it frequently. That makes me wonder why I would prefer if(stringVar.length > 0) over if(stringVar), yet I would prefer alert(stringVar || "Empty!") over the alternative if/else. I suppose it comes down to the... read more »
-
Javascript's Implicit Boolean Conversions
Posted on Mar 22, 2010 at 10:08 AM
I would certainly still use if(strValue.length > 0) over if(strValue) simply because I believe it makes the code more self-documenting. Not everyone knows that an empty string evaluates to false. Any developer (hopefully) can look at if(strValue.length > 0) and tell that you're checking for ... read more »