Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ngallagher committed Feb 5, 2019
1 parent fb12fa8 commit c86bca0
Showing 1 changed file with 40 additions and 17 deletions.
57 changes: 40 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Here you will get an overview on how the interpreter works and the language.
* [Collections](#collections)
* [Operators](#operators)
* [Arithmetic Operators](#arithmetic-operators)
* [Bitwise Operators](#bitwise-operators)
* [Relational Operators](#relational-operators)
* [Bitwise Operators](#bitwise-operators)
* [Logical Operators](#logical-operators)
* [Conditions](#conditions)
* [If Statement](#if-statement)
Expand Down Expand Up @@ -369,12 +369,15 @@ let descending = [0 from 9]; // range of decreasing numbers
### Operators
Operators are special symbols that perform specific operations on one, two, or three operands, and then return a result. They are typically used to manipulate or compare values.
Operators are special symbols that perform specific operations on a set of operands. The operators
available are those found in most conventional imperative languages, such as those to perform
algebra or compare values.
#### Arithmetic Operators
Arithmetic operators are used in mathematical expressions in the same way that they are used in algebra.
These operations can be grouped and order can be specified using braces.
```js
let a = 10;
Expand All @@ -388,21 +391,7 @@ let h = a++; // a is 11 and h is 10
let i = b--// b is 19 and i is 20
let j = --a; // a is 10 and j is 10
let k = ++b; // b is 20 as is k
```
#### Relational Operators
Relational operators are used to make comparisons, such as equal to, not equal to, greater than, less than.
```js
let a = 10;
let b = 20;
let c = a == b // equal operator, c is false
let d = a != b; // not equal operator, d is true
let e = a > b; // greater than operator, e is false
let f = a < b; // less than operator, f is true
let g = a <= b; // g is false
let h = a >= b; // h is true
let l = 1 / ((a + b) * 10)
```
#### Bitwise Operators
Expand All @@ -421,6 +410,40 @@ let h = f << 2; // h is 11000000
let i = f >>> 2; // unsigned shift, i is 00110000
```
Both the arithmetic and bitwise operators have priority and are evaluated in a specific order if no
braces are used to group or enforce order. The evaluation order applied is shown in the table below.
|Order| Operator | Description |
|-----| ------------- | ------------- |
|1 |&#42;&#42; |Exponential operator|
|2 |/ |Divide operator|
|3 |&#42; |Multiply operator|
|4 |% |Modulus operator|
|5 |+ |Addition operator|
|6 |- |Subtraction operator|
|7 |&gt;&gt; |Signed shift right operator|
|8 |&lt;&lt; |Shift left operator|
|9 |&gt;&gt;&gt; |Shift right operator|
|10 |& |Bitwise AND operator|
|11 |&#124; |Bitwise OR operator|
|12 |^ |Bitwise XOR operator|
#### Relational Operators
Relational operators are used to make comparisons, such as equal to, not equal to, greater than, less than.
```js
let a = 10;
let b = 20;
let c = a == b // equal operator, c is false
let d = a != b; // not equal operator, d is true
let e = a > b; // greater than operator, e is false
let f = a < b; // less than operator, f is true
let g = a <= b; // g is false
let h = a >= b; // h is true
```
#### Logical Operators
Logical operators are typically used to combine multiple relational operations in to a single boolean result.
Expand Down

0 comments on commit c86bca0

Please sign in to comment.