4 ms·
It's better than return foo ? true : false; or even return foo == true ? true : false;
by Leszek 13y ago
It's better than
return foo ? true : false;
or even
return foo == true ? true : false;
- deleted 13y ago[deleted]
- wreegab 13y agoSo transposing a boolean into a boolean is better than transposing a truthy value of an unspecified type into a boolean? You are missing the point, which is it's really silly to transpose a boolean into a boolean using a ternary operator. If you want to argue that "foo == null" is the problem due implicit nil value falseness, than the solution is simply to use strict comparison operator "===", transposing "foo == null" into a boolean doesn't solve the falseness issue if you think this is what the original author was trying to address.