Skip to content

Commit 10e6f3a

Browse files
committed
Add binary and octal questions
1 parent 73d547e commit 10e6f3a

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
2323
5. Stage 4: Finished.
2424

2525

26+
## Version History
27+
28+
| Edition | Date |
29+
| --- | --------- |
30+
| ES2015 Or ES6 | June2015 |
31+
| ES2016 Or ES7 | June2016 |
32+
| ES2017 Or ES8 | June2017 |
33+
| ES2018 Or ES9 | June2018 |
34+
| ES2019 Or ES10 | June2019 |
35+
| ES2020 Or ES11 | June2020 |
36+
37+
2638
### Table of Contents
2739

2840
| No. | Feature |
@@ -50,6 +62,7 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
5062
|20 | [Promises](#promises) |
5163
|21 | [Reflect](#reflect) |
5264
|22 | [Binary and Octal](#binary-and-octal) |
65+
|23 | [Proper Tail calls](#proper-tail-calls)|
5366
| | **ES2016 Or ES7** |
5467
|1 | [Array includes](#array-includes) |
5568
|2 | [Exponentiation Operator](#exponentiation-operator) |
@@ -881,6 +894,55 @@ console.log(Reflect.get(user, 'age')); // 33
881894
882895
6. **:**
883896
897+
### Binary and Octal
898+
ES5 provided numeric literals in octal (prefix 0), decimal (no prefix), and hexadecimal ( 0x) representation. ES6 added support for binary literals and improvements on octal literals.
899+
900+
**1. Binary literals:**
901+
902+
Prior to ES5, JavaScript didn’t provide any literal form of binary numbers. So you need to use a binary string with the help of `parseInt()`
903+
904+
```js
905+
const num = parseInt('111',2);
906+
console.log(num); // 7
907+
```
908+
909+
Whereas ES6 added support for binary literals using the **0b** prefix followed by a sequence of binary numbers (i.e, 0 and 1).
910+
911+
```js
912+
const num = 0b111;
913+
console.log(num); // 7
914+
```
915+
916+
**2. Octal literals:**
917+
918+
In ES5, to represent an octal literal, you use the zero prefix (0) followed by a sequence of octal digits (from 0 to 7).
919+
920+
```js
921+
const num = 055;
922+
console.log(num); // 45
923+
924+
let invalidNum = 058;
925+
console.log(invalidNum); // treated as decimal 58
926+
```
927+
928+
Whereas ES6 represents the octal literal by using the prefix **0o** followed by a sequence of octal digits from 0 through 7.
929+
930+
```js
931+
const num = 055;
932+
console.log(num); // 45
933+
934+
const invalidNum = 058;
935+
console.log(invalidNum); // treated as decimal 58
936+
```
937+
938+
Remember If you use an invalid number in the octal literal, JavaScript will throw a SyntaxError as below,
939+
940+
```js
941+
const invalidNum = 058;
942+
console.log(invalidNum); // SyntaxError
943+
```
944+
945+
884946
### Proper Tail Calls
885947
**Proper tail call(PTC)** is a technique where the program or code will not create additional stack frames for a recursion when the function call is a tail call.
886948
@@ -1340,6 +1402,7 @@ console.log(Reflect.get(user, 'age')); // 33
13401402
```
13411403
13421404
### Symbol description
1405+
13431406
While creating symbols, you also can add a description to it for debugging purposes. But there was no method to access the description directly before ES2019. Considering this, ES2019 introduced a read-only description property to retrieve a string containing the description of the Symbol.
13441407
13451408
This gives the possibility to access symbol description for different variations of Symbol objects

0 commit comments

Comments
 (0)