Operators
#
Relational OperatorsRelational operators compare two given values and return a boolean value, most commonly used in conditional statements.
The following is a list of Relational Operators:
#
Equals (==)Example:
x == y; // True if x is equal to y, otherwise false1 == 2; // False
#
Not Equals (!=)Example:
x != y; // True if x is not equal to y, otherwise false1 != 2; // True
#
Less than (<)Example:
x < y; // True if x is lesser than y, otherwise false1 < 2; // True
#
Greater than (>)Example:
x > y; // True if x is greater than y, otherwise false1 > 2; // False
#
Less than or equal to (<=)Example:
x <= y; // True if x is lesser than or equal to y, otherwise false1 <= 2; // True
#
Greater than or equal (>=)Example:
x >= y; // True if x is greater than or equal to y, otherwise false1 >= 2; // False
#
Arithmetic OperatorsArithmetic operators are used to perform calculations on numerical values, as well as to concatenate two or more string values.
The following is a list of Arithmetic Operators:
#
Add(+)To add numerical values and to concatenate string values.
Example:
a = 5;b = 5;c = a + b; // c= 10
First_Name = "John";Last_Name = "Smith";Name = First_Name + Last_Name; // Name = "John Smith"
#
Subtract(-)To perform subtraction between numerical values.
Example:
a = 5;b = 5;c = a - b; // c= 0
#
Multiply(*)To perform multiplication of numerical values.
Example:
a = 5;b = 5;c = a * b; // c= 25
#
Division(/)To perform division of numerical values.
Example:
a = 5;b = 5;c = a / b; // c= 1
#
Module(%)To calculate the remainder when a numerical value is divided by another.
Example:
a = 5;b = 5;c = a % b; // c= 0
#
Logical OperatorsLogical operator is a symbol or word used to connect two or more expressions such that the value of the compound expression produced depends only on that of the original expressions and on the meaning of the operator.
The following is a list of Logical Operators:
#
And(&&)AND operator returns true when both the conditions under consideration are satisfied or are true. If even one of the two is false, the operator results false.
Example:
a = 10;b = 20;c = 20;d = 0; if ((a < b) && (b == c)){ log "success"; }else{ log "fail"; } //success
#
Or(||)AND operator returns true when any one of the conditions under consideration are satisfied or are true. If both the conditions fail, the operator results false.
Example:
a = 10;b = 20;c = 0;d = 20; if ((a < b) || (b == c)){ log "success"; }else{ log "fail"; } //success
#
NOT(!)NOT operator if the condition is false, the operation returns true and when the condition is true, the operation returns false.
Example:
a = 10;b = 20;if (!(a > b)){ log "sucess"; }else{ log "fail"; } //success