When is (true == x) === !!x false?

Posted by Paul S. on Stack Overflow See other posts from Stack Overflow or by Paul S.
Published on 2012-11-25T16:57:36Z Indexed on 2012/11/25 17:04 UTC
Read the original article Hit count: 156

Filed under:

JavaScript has different equality comparison operators

  • Equal ==
  • Strict equal ===

It also has a logical NOT ! and I've tended to think of using a double logical NOT, !!x, as basically the same as true == x.

However I know this is not always the case, e.g. x = [] because [] is truthy for ! but falsy for ==.

So, for which xs would (true == x) === !!x give false? Alternatively, what is falsy by == but not !! (or vice versa)?

© Stack Overflow or respective owner

Related posts about JavaScript