4 ms·
Not for comparison, but for boolean checks I prefer to use `foo == false` instead of `!foo`, the latter is easy to overlook.
by rplnt 6y ago
Not for comparison, but for boolean checks I prefer to use `foo == false` instead of `!foo`, the latter is easy to overlook.
- franga2000 6y agoI've recently started using a kind of middle ground by putting spaces around the !. Makes it harder to miss without losing the "reads like text" property that's lost when using == false. if ( ! isLast(e) ) reads perfectly, especially since my native language doesn't insert the "not" im the middle like english does and my brain is used to that. if (isLast(e) == false) just jolts me out of that state where code reads as fluently as text. YMMV, of course, and I have a suspicion that your native language might play a role in that...
- dylan604 6y agoDo all languages have `foo === false`? When testing booleans, I always do the type specific test to avoid `foo = 0 !== false` stuff
- Jenz 6y ago> Do all languages have ... Of course not