Strict Inequality (!==) Comparison Operator

Summary

Compares two expressions for value and type inequality.

Syntax

expression1 !== expression2

Parameters

expression1
Any legal expression.
expression2
Any legal expression.

Description

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

This operator is inherited from JavaScript. If your code uses JS++ types only (such as the int type), strict inequality may be redundant. This is because the types are already checked by the JS++ type checker at compile time.

1
2
3
4
5
6
import System;
 
int x = 1, y = 2;
 
Console.log(x !== y); // Redundant, type is already checked at compile time
Console.log(x != y);  // Has the same meaning for non-external (JS++) types

However, if at least one side of the comparison expression uses JavaScript types (declared with var, function, or external), it is recommended to use the strict inequality operator:

1
2
3
4
5
6
import System;
 
int x = 1;
var y = "1";
 
Console.log(x !== y); // 'y' has external (JavaScript) type. Use strict inequality (!==) over regular inequality (!=).

Examples

Comparing JavaScript Types and Values
1
2
3
4
5
import System;
 
var x = 1, y = 1, z = "1";
Console.log(x !== y); // false
Console.log(y !== z); // true

See Also

Share

HTML | BBCode | Direct Link