DEV Community

Discussion on: 2 Ways to Convert Values to Boolean in JavaScript

Collapse
 
moopet profile image
Ben Sinclair

It's not really coercion, or I don't think it goes that far. It's just that !! is saying "make this a boolean if it's "truthy" and you can just use the "is it truthy" instead.

Casting to boolean is only useful if you're going to do something like supply it to an API that expects a boolean.