Here is a Ruby/JavaScript dictionary of some Ruby operators.
| Python | JavaScript | Meaning | Python Return Type |
Python Precedence |
|---|---|---|---|---|
| ( ) | ( ) | parentheses for grouping | 1 | |
| f(x) | f(x) | function evaluation | 2 | |
| a[i] | a[i] | ith element of array a | Type of array element | 3 |
| s.upper( ) | n.toString() | dot operator: attribute selection |
4 | |
| a ** n | Math.pow(a, n) | a raised to the n power | float | 5 |
| !expr | !expr | if expr is
true, return false; if false, return true |
bool | 6 |
| +5 | +5 | positive 5 (not usually used) | int or float | 7 |
| -5 | -5 | negation of 5 | int or float | 7 |
| x * y | x * y | x multiplied by y | int or float | 8 |
| x / y | x / y | x divided by y | float | 8 |
| x // y | x / y | x divided by y, integer division |
int | 8 |
| x % y | x % y | x mod y (remainder from integer division) |
int or float | 8 |
| x + y | x + y | sum of x and y | int or float | 9 |
| s + t | s + t | concatenate s and t | str | 9 |
| x - y | x - y | difference of x minus y | int or float | 9 |
| x < y | x < y | x is less than y | bool | 10 |
| x > y | x > y | x is greater than y | bool | 10 |
| x <= y | x <= y | x is less than or equal to y | bool | 10 |
| x >= y | x >= y | x is greater than or equal to y | bool | 10 |
| x == y | x == y | x is equal to y | bool | 10 |
| x != y | x != y | x is not equal to y | bool | 10 |
| not expr | !expr | logical not | bool | 11 |
| expr1 and expr2 | expr1 && expr2 | logical and | bool | 12 |
| expr1 or expr2 | expr1 || expr2 | logical or | bool | 13 |
| y = x | y = x; | assign value of x to y | Type of x | 14 |