That’s all we can say right now.
In contexts such as an if
statement's test where the result of the expression will already be coerced to a Boolean
, casting to a Boolean
via double negation (!!
) or a Boolean
call is unnecessary.
const cond = !!!isPresent;
const cond2 = Boolean(!!isPresent);
if (!!cond) {
// ...
}
if (Boolean(cond2)) {
// ...
}
while (!!cond3) {
// ...
}
do {
// ...
} while (Boolean(cond));
for (; !!cond; ) {
// ...
}
const cond = !!isPresent;
const cond2 = Boolean(isPresent);
function checkCond() {
return !!isPresent;
}
const cond3 = !!(isPresent ? flag : flag2);