3 ms·
Right on, I get that, but truthy(NaN) and truthy(5) both return true, so you still don't know if the calculation isNaN. Btw, I should have said first: I love t
by dweinus 13y ago
Right on, I get that, but truthy(NaN) and truthy(5) both return true, so you still don't know if the calculation isNaN.
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!
- fogus 13y agoI would probably structure the problem like this: 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. :-)