Equality Operator (==)

By: Dusty Arlia
Published on September 26, 2012
Last Updated on Thursday, July 16, 2015 at 7:09 PM
Total Updates: 6

Whenever you see two equal sign in arrow (==), this is the equality operator. Do not confuse the equality operator with the assignment operator which is only one equal sign (=). What the equality operator does is it compares the two values on each side of itself and determines if they are equal or not. If they are equal, then this condition is true. The program will then execute the code in between the two curly braces (true, do).

If these two values aren't equal, then this condition is false. The code in between the two curly braces is skipped over and the program continues to run.

Here is an example of the equality operator in use:

if (inning == 10) {
alert('Game Over');
} 

In this example, if the variable inning equals the number 10, then the message Game Over gets displayed in an alert box. If the variable inning does not equal 10, then the code in between the curly braces is skipped over and the program would continue to run.

Comments:

Ad: