Inequality (!=) Comparison Operator

Summary

Compares two expressions for value inequality.

Syntax

expression1 != expression2

Parameters

expression1
Any legal expression.
expression2
Any legal expression.

Description

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

If your code uses JavaScript code (such as symbols declared with var, function, or external), the inequality 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); // false
Console.log(y != z); // true
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 not 1");
}
else {
    Console.log("x is 1");
}

See Also

Share

HTML | BBCode | Direct Link