False, True

Hi,

I got task:

a == false
!a == false
a == !a

As I understund, const a should be equal to false, because:

a = 10
a == false                     // true
!a == false                    // false
a == !a                        // false

Could somebody explain me this?
Thank you in advance.

I’m not sure what you’re getting at here. a is equal to 10, as you set it to ten.

Also:

a = 10
a == false                     // false
!a == false                    // true
a == !a                        // false

Did I miss something?

1 Like

Nope, it equals true (only false, null, undefined, 0, and '' are falsy)

You may find this article helpful:

Hint: The answer is a combination of the values @Dormilich mentioned… so much for the loose equality comparison. :-P

Thank you :slight_smile:

As a result, it’s best to stay away from the loose equality comparison and stick with the strict triple equals === comparison instead.

1 Like

Unless of course you want to write orthodox JS… :-)

4 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.