Here is a quick tip for JavaScript falsy conditions for programmers or for people who come from Java or C#.
In Java and C# when we thinks of using a compare conditions in a if statements, we tend to use something along the line of:
|
1 2 3 |
if(val != null && val.length > 0) { //do stuff } |
We tend to bring this baggage of knowledge to JavaScript also, but it is not necessary. In JavaScript one can simply use the conditionals as below.
|
1 2 3 |
if(val) { //do something } |
… Read the rest “Learn to love the JavaScript falsy conditions”


