Reputation: 35213
Why is Resharper saying that the expression is alwaus true? It's !!bar
that is highlighted.
I would say that if it should say anything at all about it, it could say that it's always false. Or am I loosing my mind?
function foo(bar){
bar = !bar ? !!bar : bar;
}
My thought here is that if bar
is undefined
, it will evaluate to false
and be converted to a boolean
.
Upvotes: 0
Views: 112
Reputation: 2354
I can't answer why resharper says that, but if what you want is to coerce the value into a booolean, couldn't you rewrite it bar = !!bar
?
Upvotes: 2