3 ms·
In that sort of case I like to use explicit type casting, e.g. if (Number(myNum) === 2) {} For me this also extends to using `Boolean(val)` instead of `!!
by kenbellows 8y ago
In that sort of case I like to use explicit type casting, e.g.
if (Number(myNum) === 2) {}
For me this also extends to using `Boolean(val)` instead of `!!val`, etc.; though I understand the appeal of those nifty one-liners, I think they cause confusion in many places and don't communicate intent nearly as well.