Sorry to nitpick, but I got hung up right at the beginning with his "truthy" function.
It returns true on values such as NaN, zero, or an empty string. I don't think I'm alone in considering those to be "falsy" values, for example:
It returns true on values such as NaN, zero, or an empty string. I don't think I'm alone in considering those to be "falsy" values, for example:
Btw, I should have said first: I love the article in general and it's great to see these techniques becoming more mainstream in javascript. Thank you!
var ans = someCalculation(x,y);
if (truthy(ans) && !isNaN(ans))
//do something
else
//do something else
The point being I like to dispatch conditions on boolean results of certain properties of my results rather than the result directly. It helps me to keep my sanity.Thanks for the kind words BTW. :-)