If/else statement ( === vs = )

I’m new to to this forum and javascript, so apologies if this has already been covered.

I was curious if my assumption regarding if/else statements is a correct. When defining the condition, for example if (isSoccerFan === true), I noticed that if I use only one = symbol, it checks for the opposite case. I.E. (isSoccerFan = true) is actually checking the condition that I am not a soccer fan.

Don’t know if this was just a bug of the system or if my assumption is actually correct.
Thanks in advance!

Control Flow

Known as an identity operator it is strictly type matched, meaning both operands have to be the same data type.

Known as the assignment operator, it is never used in comparisons.


is also a comparison operator, known as coercive equality. This operator will convert one of the operands to the same data type of the other operand, if possible.

42 == "42"    //  true
1 Like

Ok. Thanks for the clarification. Obviously still very new to all this.

1 Like

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