if results is an array, e.g. [ ] `!!results === tr...
# suitescript
j
if results is an array, e.g. []
!!results === true
r
are you saying !!results is different than results? i use
if (results) {
to weed out null values...
nevermind, just got it. interesting
s
FWIW, I almost never use this
!!
coercion to bool... it seems native truthy/falsey covers most use cases for this. The exception for me is if I require a boolean for strong typing (e.g. something in TypeScript requires a boolean). I'd love to hear other ideas on using (or not using)
!!
j
Right, since boolean operators and if statements coerce values, any code you write using
!!
will likely have the same effects as if you did not use
!!
. I sometimes use it when it knowing that a symbol is a boolean (and not, e.g. an array) improves the clarity of the code, or if I am returning a value from a function the return value should definitely be a boolean and not leak e.g. an array of results.