2 ms·
I tend to avoid the ternary operator because in my experience even people who think they know how it works are often unaware of its edge cases when it comes to
by brmgb 7y ago
I tend to avoid the ternary operator because in my experience even people who think they know how it works are often unaware of its edge cases when it comes to silent numeric type conversion (looking at you Java).
If you don't put the same type on each return sides of your ternary, you might be in for a nasty surprise.
- maxxxxx 7y ago“If you don't put the same type on each return sides of your ternary, you might be in for a nasty surprise.” Definitely true for JavaScript and PHP. I am always surprised what expressions can evaluate to true or false.