Skip to main content
May 6, 2014
Question

What is the different between variable == 1 and variable = 1?

  • May 6, 2014
  • 1 reply
  • 168 views

What is the different between variable == 1 and variable = 1?

One = sign and Two = signs?

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
May 6, 2014

the double equal (==) is used for testing equality.  the single equal (=) is the assignment operator.

var1 = 1;  // assigns the value of 1 to the variable var1

if(var1==1){

// this executes if var1 has a value of 1

} else {

// this executes if var1 has a value other than 1

}