Comparison Operators

Use comparison operators to measure values against each other. The data types of compared values must match, otherwise the application will return an error. The result of a comparison operation is a Boolean, true or false.

Operator

Name

Description

Applicable Data Types

Return Data Type

Example

==

Equal

Tests if two values are equal.

All

Boolean

1.0 == 1.0;
//returns true

1.0 == 2.3
//returns false

"Hello" == "Hello" //returns true

 

 

!=

Does Not Equal

Tests if two values are not equal.

All

Boolean

2 + 2 != 5;
//returns true

2 + 2 != 4;
//returns false

"Hello" != "Goodbye" //returns true

 

 

>

Greater Than

Tests if one value is greater than another.

All

Boolean

50 > 100; //returns false

50 > 5; //returns true

"2" > "10" //returns true

"Hello" > "World" //returns false

5 > "4" //error. The types of compared values must match.

 

 

>=

Greater Than or Equal To

Tests if one value is greater than or equal to another

All

Boolean

60 >= 50; //returns true

60 >= 70 //returns false

60 >= 60 //returns true

"Hello" >= "World" //returns false

 

 

<

Less Than

Tests if one value is less than another.

All

Boolean

50 < 100; //returns true

50 < 40 //returns false

"2"< "10" // returns false

"Hello" < "World" //returns true

"3/1/17" < new Date() //error the types of compared values must match

 

 

<=

Less Than or Equal To

Tests if one value is less than or equal to another.

All

Boolean

60 <= 50; //returns false

60 <= 90 // returns true

60 <= 60 //returns true

"10" <= "2" //returns true

 



Legal Notices | Your Privacy Rights
Copyright © 2019, 2022

Last Published Thursday, August 25, 2022