Javascript: Detailed differences between !variable and variable == false?

I accidentally got undefined == true and undefined == false that both of them returns false.

But !undefined returns true.

And this is the question:

What’s the algorithmic difference(s) between !someVariable and someVariable == false?

If i want to explain it more, type undefined == false ? 't' : 'f' in your browser’s console, and it returns, 'f' ( as explained above ).

But if you type !undefined ? 't' : 'f' it returns 't'.

So obviously there’s difference(s) between them and how they’re working.


Source: javascript

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.