re: Yes, it will work but ESLint will mark it as redundant negation. IMHO it is better to use Boolean(...).

ESLint is opinionated and only as good as its configuration...


Someone had to make the initial configuration and even put in time to build the rule. Perhaps digging into why they took the time to do this can provide an idea as to why double negation could present possible friction.

As someone pointed out below, using !! is less obvious at a glance and take mental effort to decipher meaning. Don't get me wrong, it's important to know about and to share with people! But the alternative of using Boolean() is certainly worth exploring rather than simply ruling out for no reason.

using !! is less obvious at a glance

imho, depends on how used you are to seeing it. I am not used to seeing Boolean(), so it causes more friction to me than !! 😉

All in all, I think it's just another way to do something in the already rather ambiguous JS language, and I'd put it right in line with for..of vs .forEach() or the usage of semicolons. There's arguments on both sides and it comes down to the person writing the code.

Whenever I do a code-review and see either, I just skip it for that very reason, if there are no strong arguments for using exactly one of them.

code of conduct - report abuse