News for hackers. Stuff that matters.
Re:JavaScript Equality Minesweeper by tenaciousDaniel on Monday September 17, 2018 @10:12AM (#18006064)
yeah if I'm doing any kind of loose type-checking I make it explicit.

if (myNum === 2 || myNum === '2') {}

It's very easy for developers to mistakenly "see" the third equality symbol and get confused by the intent of the code.

Re:JavaScript Equality Minesweeper by kenbellows on Monday September 17, 2018 @12:58PM (#18007674)
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.