Operators
Learn about all the equations you can form.
There are set of valid operations that you can use with each data type. Some of which are unary operations, i.e. require
one parameter, and others are binary operations, i.e. require two parameters.
Number Operations
Binary Operations
Operation | Name | Function | Return Type | Example |
---|
+ | Addition | Adds two numbers and returns the result | Number | |
- | Subtraction | Subtract two numbers and returns the result | Number | |
* | Multiplication | Multiplies two numbers and returns the result | Number | |
\ | Division | Divides two numbers and returns the result | Number | |
% | Modulo | Divides two numbers and returns the remainder | Number | |
Binary Logical Operations
Operation | Name | Function | Return Type | Example |
---|
> | Greater Than | Checks if the first number is greater than the second and returns the result | Boolean | |
< | Less Than | Checks if the first number is less than the second and returns the result | Boolean | |
>= | Greater Than or Equal | Checks if the first number is greater than or equal to the second and returns the result | Boolean | |
<= | Less Than or Equal | Checks if the first number is less than or equal to the second and returns the result | Boolean | |
== | Equal | Checks if the first number is equal to the second and returns the result | Boolean | |
!= | Not Equal | Checks if the first number is not equal to the second and returns the result | Boolean | |
Binary Assignment Operations
Operation | Name | Function | Return Type | Example |
---|
+= | Add and Assign | Adds a number to the original one and returns the new result | Number | |
-= | Subtract and Assign | Subtracts a number from the original one and returns the new result | Number | |
*= | Multiply and Assign | Multiplies a number to the original one and returns the new result | Number | |
\= | Divide and Assign | Divides by a number the original one and returns the new result | Number | |
Unary Operations
Operation | Name | Function | Return Type | Example |
---|
- | Negative | Returns the value of a number multiplied by -1 | Number | |
Postfix Operations
Operation | Name | Function | Return Type | Example |
---|
++ | Addition Postfix | Adds 1 to the number and returns the old value | Number | |
-- | Subtraction Postfix | Subtracts 1 from the number and returns the old value | Number | |
Prefix Operations
Operation | Name | Function | Return Type | Example |
---|
++ | Addition Prefix | Adds 1 to the number and returns the new value | Number | |
-- | Subtraction Prefix | Subtracts 1 from the number and returns the new value | Number | |
Boolean Operations
Binary Operations
Operation | Name | Function | Return Type | Example |
---|
&& | AND | Returns true if the conditions are true, false otherwise | Boolean | |
|| | OR | Returns true if the any of the conditions is true, false otherwise | Boolean | |
== | Equal | Returns true if the conditions are equal, false otherwise | Boolean | |
!= | Not Equal | Returns false if the conditions are equal, true otherwise | Boolean | |
Unary Operations
Operation | Name | Function | Return Type | Example |
---|
! | NOT | Returns true if the condition is false, false otherwise | Boolean | |
String Operations
Binary Operations
Operation | Name | Function | Return Type | Example |
---|
+ | Concatenation | Adds two strings or a string and a number together and returns the result | String | "مرحبا" + " بالعالم" الجواب هو :" + 10"
|
== | Equal | Returns true if the strings are equal, false otherwise | Boolean | |
!= | Not Equal | Returns false if the strings are equal, true otherwise | Boolean | |
Binary Assignment Operations
Operation | Name | Function | Return Type | Example |
---|
+= | Concatenate | Concatenates a number or a string to the original one and returns the result | String | |
*= | Repeat | Repeats the target string N times, updating it with the new value, and returning the result | String | |