How does 1 !==true output false?

I am learning about the Inequality Operator and I came across this example:

1 != true   // false
0 != false  // false

I am having trouble understanding how 1 “not equal” to true is false and 0 “not equal” to false is also false. Can someone explain? Thank you.

1 Like

You are not checking for strict equality. When treated as a boolean, 0 is considered false and 1 is considered true.

1 != true ; // false
1 !== true; // true due to strict equality
0 != false; // false
0 !== false; // true due to strict equality

Ahh I see–I didn’t realize 1 and 0 can be treated as booleans. Thank you!

Anything can be treated as a boolean. Everything is either “truthy” or “falsy”.

I see. I’ll have to read up more on that concept