2 ms·
Your example should really be (using a polyfill if necessary) if(someStr.includes('John')) {...} While I don't mind it for containers, I've never liked usin
by icebraining 11y ago
Your example should really be (using a polyfill if necessary)
if(someStr.includes('John')) {...}
While I don't mind it for containers, I've never liked using Boolean coercion for numbers. Zero is obviously a special case, but I don't think it maps well with the True/False dichotomy.
- jewel 11y agoZero doesn't have to be a special case. In ruby 0 is a truthy value, as well as the empty string. The only things that are falsey are false and nil. Truthy/falsey means when used in a conditional or after a unary !. So you still get strong typing, e.g. false == nil is not a true statement.