Operators
Operators is a symbol which is used to perform operations on variables and values. For example, + is an operator used to perform addition. It tells the compiler to perform the addition of two numbers.
Arithmetic Operators
Addition Operator
- The
+operator is used to add two numbers.
let a = 10;
let b = 20;
let c = a + b;
print(c);
Console
30Subtraction Operator
- The
-operator is used to subtract two numbers.
let a = 20;
let b = 10;
let c = a - b;
print(c);
Console
10Multiplication Operator
- The
*operator is used to multiply two numbers.
let a = 10;
let b = 20;
let c = a * b;
print(c);
Console
200Division Operator
- The
/operator is used to divide two numbers.
let a = 20;
let b = 10;
let c = a / b;
print(c);
Console
2Logical Operators
Equality Operator
- The
==operator is used to check if two values are equal.
let a = 10;
let b = 10;
print(a == b);
Console
trueInequality Operator
- The
!=operator is used to check if two values are not equal.
let a = 10;
let b = 20;
print(a != b);
Console
trueLess/Greater Than Operator
- The
<and>operators are used to check if a value is less than or greater than another value.
let a = 10;
let b = 20;
print(a < b);
print(a > b);
Console
true
falseLess/Greater Than or Equal Operator
- The
<=and>=operators are used to check if a value is less than or equal to or greater than or equal to another value.
let a = 10;
let b = 20;
print(a <= b);
print(a >= b);
Console
true
false