You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+80-4Lines changed: 80 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -465,6 +465,8 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
465
465
466
466
**Note:** The spread syntax is opposite of rest parameter.
467
467
468
+
**[⬆ Back to Top](#table-of-contents)**
469
+
468
470
10. ### Iterators & For..of
469
471
470
472
String, Array, TypedArray, Map, and Set are all built-in iterables but objects are not iterables by default.
@@ -511,6 +513,8 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
511
513
512
514
**Note:** The abrupt iteration termination can be caused by break, throw or return.
513
515
516
+
**[⬆ Back to Top](#table-of-contents)**
517
+
514
518
11. ### Generators
515
519
A generator is a function that can stop or suspend midway and then continue from where it stopped while maintaining the context(savedacrossre-entrances). It can be defined using a function keyword followed by an asterisk(i.e, function* ()).
516
520
@@ -532,6 +536,8 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
532
536
533
537
**Note:** We can use `yield*` to delegate to another generator function
534
538
539
+
**[⬆ Back to Top](#table-of-contents)**
540
+
535
541
12. ### Modules
536
542
Modules are small units of independent, reusable code to be used as the building blocks in a Javascript application.
537
543
@@ -608,6 +614,8 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
608
614
609
615
```
610
616
617
+
**[⬆ Back to Top](#table-of-contents)**
618
+
611
619
13. ### Set
612
620
613
621
Set is a built-in object to store collections of unique values of any type.
@@ -625,6 +633,8 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
625
633
console.log(mySet.has(2)); // true
626
634
```
627
635
636
+
**[⬆ Back to Top](#table-of-contents)**
637
+
628
638
14. ### Weakset
629
639
630
640
The Set is used to store any type of data such as primitives and object types. WhereasWeakSet is an object to store weakly held objects in a collection. (i.e, WeakSet is the collections of objects only). Here weak means, If no other references to an object stored in the WeakSet exist, those objects can be garbage collected.
@@ -650,6 +660,8 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
650
660
john = null;
651
661
```
652
662
663
+
**[⬆ Back to Top](#table-of-contents)**
664
+
653
665
15. ### Map
654
666
655
667
Map is a collection of elements where each element is stored as a Key, value pair. It can hold both objects and primitive values as either key or value and iterates its elements in insertion order.
@@ -684,6 +696,8 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
684
696
}
685
697
```
686
698
699
+
**[⬆ Back to Top](#table-of-contents)**
700
+
687
701
16. ### Weakmap
688
702
689
703
WeakMap object is a collection of key/value pairs in which the keys are weakly referenced. For this object, the keys must be objects and the values can be arbitrary values.
@@ -710,6 +724,8 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
710
724
console.log(weakMap.get(obj1)); //undefined
711
725
```
712
726
727
+
**[⬆ Back to Top](#table-of-contents)**
728
+
713
729
17. ### Unicode
714
730
715
731
Prior to ES6, JavaScript strings are represented by 16-bit character encoding (UTF-16). Each character is represented by 16-bit sequence known as code unit. Since the character set is been expanded by Unicode, you will get unexpected results from UTF-16 encoded strings containing surrogate pairs(i.e, Since it is not sufficient to represent certain characters in just 16-bits, you need two 16-bit code units).
@@ -748,6 +764,8 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
748
764
console.log(String.fromCodePoint(134071)); // "𠮷"
749
765
```
750
766
767
+
**[⬆ Back to Top](#table-of-contents)**
768
+
751
769
18. ### Symbols
752
770
753
771
Symbol is a newpeculiar primitive data type of JavaScript, along with other primitive types such as string, number, boolean, null and undefined. Thenewsymbol is created just by calling the Symbolfunction. i.e, Every time you call the Symbol function, you’ll get a new and completely unique value. You can also pass a parameter to Symbol(), which is useful for debugging purpose only.
@@ -790,6 +808,8 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
The Proxy object is used to create a proxy for another object, which can intercept and redefine fundamental operations for that object such as property lookup, assignment, enumeration, function invocation etc. These are used in many libraries and some browser frameworks.
795
815
@@ -852,6 +872,8 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
852
872
person.age = 200; // Throws an exception
853
873
```
854
874
875
+
**[⬆ Back to Top](#table-of-contents)**
876
+
855
877
20. ### Promises
856
878
857
879
A promise is an object which represent the eventual completion or failure of an asynchronous operation.
@@ -893,6 +915,8 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
893
915
});
894
916
```
895
917
918
+
**[⬆ Back to Top](#table-of-contents)**
919
+
896
920
21. ### Reflect
897
921
898
922
Reflection is the ability of a code to inspect and manipulate variables, properties, and methods of objects at runtime. JavaScript already provides `Object.keys(), Object.getOwnPropertyDescriptor(), and Array.isArray()` methods as classic refection features. In ES6, it has been officially provided through Reflect object. Reflect is a new global object which is used to call methods, construct objects, get and set properties, manipulate and extend properties.
@@ -1017,6 +1041,8 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
1017
1041
1018
1042
6. **:**
1019
1043
1044
+
**[⬆ Back to Top](#table-of-contents)**
1045
+
1020
1046
22. ### Binary and Octal
1021
1047
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.
1022
1048
@@ -1065,6 +1091,7 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
1065
1091
console.log(invalidNum); // SyntaxError
1066
1092
```
1067
1093
1094
+
**[⬆ Back to Top](#table-of-contents)**
1068
1095
1069
1096
23. ### Proper Tail Calls
1070
1097
@@ -1103,6 +1130,9 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
1103
1130
console.log(factorial(1000));
1104
1131
console.log(factorial(10000));
1105
1132
```
1133
+
1134
+
**[⬆ Back to Top](#table-of-contents)**
1135
+
1106
1136
24. ### Array find methods
1107
1137
ES6 introduced few array methods and two of them are `Array.find()` and `Array.findIndex()`.
1108
1138
@@ -1168,6 +1198,9 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
1168
1198
console.log(numbers.includes(NaN)); // true
1169
1199
console.log(numbers.includes(undefined)); // true
1170
1200
```
1201
+
1202
+
**[⬆ Back to Top](#table-of-contents)**
1203
+
1171
1204
2. ### Exponentiation Operator
1172
1205
1173
1206
The older versions of javascript uses `Math.pow` function to find the exponentiation of given numbers. ECMAScript 2016 introduced the exponentiation operator, **(similar to other languages such as Python or F#) to calculate the power computation in a clear representation using infix notation.
@@ -1213,6 +1246,9 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
1213
1246
}
1214
1247
logger();
1215
1248
```
1249
+
1250
+
**[⬆ Back to Top](#table-of-contents)**
1251
+
1216
1252
2. ### Object values
1217
1253
Similar to Object.keys which iterate over JavaScript object’s keys, Object.values will do the same thing on values. i.e, The Object.values() method is introduced to returns an array of a given object's own enumerable property values in the same order as `for...in` loop.
1218
1254
@@ -1230,7 +1266,9 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
The `Object.entries()` method is introduced to returns an array of a given object's own enumerable string-keyed property [key, value] pairsin the same order as `for...in` loop.
1236
1274
```js
@@ -1250,7 +1288,9 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
1250
1288
1251
1289
console.log(Object.entries(100)); // [], an empty array for any primitive type because it won't have any own properties
1252
1290
```
1253
-
1291
+
1292
+
**[⬆ Back to Top](#table-of-contents)**
1293
+
1254
1294
4. ### Object property descriptors
1255
1295
1256
1296
Property descriptors describe the attributes of a property. The `Object.getOwnPropertyDescriptors()` method returns all own property descriptors of a given object.
@@ -1274,6 +1314,8 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
Some strings and numbers(money, date, timers etc) need to be represented in a particular format. Both `padStart() &padEnd()` methods introduced to pad a string with another string until the resulting string reaches the supplied length.
@@ -1302,6 +1344,8 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
1302
1344
console.log(label2 +": "+ value2); // Name: John
1303
1345
// Phone Number: (222)-333-3456
1304
1346
```
1347
+
1348
+
**[⬆ Back to Top](#table-of-contents)**
1305
1349
1306
1350
6. ### Shared memory and atomics
1307
1351
The Atomics is a global object which provides atomic operations to be performed as static methods. They are used with SharedArrayBuffer(fixed-length binary data buffer) objects. The main use cases of these methods are,
@@ -1405,6 +1449,8 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
1405
1449
1406
1450
In order to access asynchronous data sources, ES2018 introduced the AsyncIterator interface, an asynchronous iteration statement (for-await-of), and async generator functions.
1407
1451
1452
+
**[⬆ Back to Top](#table-of-contents)**
1453
+
1408
1454
2. ### Object rest and spread operators
1409
1455
1410
1456
ES2015 or ES6 introduced both rest parameters and spread operators to convert arguments to array and vice versa using three-dot(...) notation.
@@ -1446,6 +1492,8 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
In order to make consistency with padStart/padEnd, ES2019 provided the standard functions named as `trimStart` and `trimEnd` to trim white spaces on the beginning and ending of a string. However for web compatilibity(avoid any breakage) `trimLeft` and `trimRight` will be an alias for `trimStart` and `trimEnd` respectively.
@@ -1567,6 +1619,8 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
Prior to ES9, if you don't need `error` variable and omit the same variable then catch() clause won't be invoked. Also, the linters complain about unused variables. Inorder to avoid this problem, the optional catch binding feature is introduced to make the binding parameter optional in the catch clause. If you want to completely ignore the error or you already know the error but you just want to react to that the this feature is going to be useful.
@@ -1613,6 +1669,9 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
1613
1669
}
1614
1670
} catch (unused) {}
1615
1671
```
1672
+
1673
+
**[⬆ Back to Top](#table-of-contents)**
1674
+
1616
1675
6. ### JSON Improvements
1617
1676
1618
1677
JSON is used as a lightweight format for data interchange(to read and parse). The usage of JSON has been improved as part of ECMAScript specification. Basically there are 2 important changes related to JSON.
@@ -1644,6 +1703,8 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
The sort method for arrays is stable in ES2020. i.e, If you have an array of objects and sort them on a given key, the elements in the list will retain their position relative to the other objects with the same key.
@@ -1666,6 +1727,7 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
1666
1727
]
1667
1728
users.sort((a, b) =>a.age-b.age);
1668
1729
```
1730
+
**[⬆ Back to Top](#table-of-contents)**
1669
1731
1670
1732
8. ### Function.toString()
1671
1733
Functions have an instance method called `toString()` which return a string to represent the function code. Previous versions of ECMAScript removes white spaces,new lines and comments from the function code but it has been retained with original source code in ES2020.
@@ -1684,6 +1746,8 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
1684
1746
// console.log(`Hello, ${msg}`);
1685
1747
// }
1686
1748
```
1749
+
1750
+
**[⬆ Back to Top](#table-of-contents)**
1687
1751
1688
1752
9. ### Private Class Variables
1689
1753
In ES6, the classes are introduced to create reusable modules and variables are declared in clousure to make them private. Where as in ES2020, private class variables are introduced to allow the variables used in the class only. By just adding a simple hash symbol in front of our variable or function, you can reserve them entirely for internal to the class.
@@ -1747,6 +1811,8 @@ Most of these features already supported by some browsers and try out with babel
1747
1811
console.log(1n==1); // true
1748
1812
```
1749
1813
1814
+
**[⬆ Back to Top](#table-of-contents)**
1815
+
1750
1816
2. ### Dynamic Import
1751
1817
Static imports supports some of the important use cases such as static analysis, bundling tools, and tree shaking, it is also it's desirable to be able to dynamically load parts of a JavaScript application at runtime.
1752
1818
@@ -1784,6 +1850,8 @@ Most of these features already supported by some browsers and try out with babel
1784
1850
1785
1851
**Note:** Dynamic import does not require scripts of `type="module"`
1786
1852
1853
+
**[⬆ Back to Top](#table-of-contents)**
1854
+
1787
1855
3. ### Nullish Coalescing Operator
1788
1856
The nullish coalescing operator (??) is a logical operator that returns its right-hand side operand when its left-hand side operand is `null` or `undefined`, and otherwise returns its left-hand side operand. This operator replaces `||` operator to provide default values if you treat empty value or '', 0 and NaN as valid values. This is because the logical OR(||) operator treats(empty value or '', 0 and NaN) as falsy values and returns the right operand value which is wrong in this case. Hence, this operator truely checks for `nullish` values instead `falsy` values.
1789
1857
```js
@@ -1801,6 +1869,8 @@ Most of these features already supported by some browsers and try out with babel
1801
1869
console.log(vehicle.car.speed??90); // 0(zero is valid case for speed)
1802
1870
```
1803
1871
In a short note, nullish operator returns a non-nullish value and || operator returns truthy values.
1872
+
1873
+
**[⬆ Back to Top](#table-of-contents)**
1804
1874
1805
1875
4. ### String matchAll
1806
1876
@@ -1818,6 +1888,8 @@ Most of these features already supported by some browsers and try out with babel
It is really helpful to log(especially to debug errors) about each promise when you are handling multiple promises. The `Promise.allSettled()` method returns a new promise that resolves after all of the given promises have either fulfilled or rejected, with an array of objects describing the outcome of each promise.
1854
1928
```js
@@ -1863,7 +1937,9 @@ Most of these features already supported by some browsers and try out with babel
1863
1937
```
1864
1938
As per the output, each outcome object returns `status` field which denotes either "fulfilled"(value present) or "rejected"(reason present)
1865
1939
1866
-
6. ### globalThis
1940
+
**[⬆ Back to Top](#table-of-contents)**
1941
+
1942
+
7. ### globalThis
1867
1943
Prior to ES2020, you need to write different syntax in different JavaScript environments(cross-platforms) just to access the global object. It is really a hard time for developers because you need to use `window, self, or frames` on the browser side, `global` on the nodejs, `self` on the web workers side.
1868
1944
1869
1945
On the other hand, `this` keyword can be used inside functions for non-strict mode but it gives undefined in strict mode. If you think about `Function('return this')()` as a solution for above environments, it will fail for CSP enabled environments(where eval() is disabled).
0 commit comments