Why use === in an if else statement instead of a single =


#1

I don’t understand why you need to use three = when setting the value of your variable to either true or false,
if (isSoccerFan === true)
instead of using only a single = ,
if (isSoccerFan = true)
can someone explain this?

Also is this notation only used for boolean values or for other values as well?


#2

= assign a value to a variable, while === does comparison.

if (isSoccerFan = true) condition is always true, even when isSoccerFan would be false.


#3

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