Equality (==) Comparison Operator

Summary

Compares two expressions for value equality.

Syntax

expression1 == expression2

Parameters

expression1
Any legal expression.
expression2
Any legal expression.

Description

The equality operator compares the values of two expressions. The equality operator returns true if the resulting values of the expressions are equal and false otherwise.

If your code uses JavaScript code (such as symbols declared with var, function, or external), the equality operator will additionally - at runtime - convert the values of the expressions to the same type before comparing the values of the results.

Examples

Comparing Values
1
2
3
4
5
import System;
 
int x = 1, y = 1, z = 2;
Console.log(x == y); // true
Console.log(y == z); // false
Comparing Values in an 'if' statement
1
2
3
4
5
6
7
8
9
10
import System;
 
int x = 1;
 
if (x == 1) {
    Console.log("x is 1");
}
else {
    Console.log("x is not 1");
}

See Also

Share

HTML | BBCode | Direct Link