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
+39-39Lines changed: 39 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,12 +5,12 @@
5
5
## How to run examples
6
6
```cmd
7
7
npm install
8
-
npx babel-node es2020/bigint // Try other examples too
8
+
npx babel-node es2020\bigint.js # Try other examples too
9
9
```
10
10
11
11
# What is ECMAScript?
12
12
13
-
**ECMAScript** is the scripting language which acts as the basis of JavaScript. ECMAScript standardized by the ECMA International standards organization in the ECMA-262 and ECMA-402 specifications.
13
+
**ECMAScript** is the scripting language which acts as the basis of JavaScript. ECMAScript is standardized by the ECMA International standards organization in the ECMA-262 and ECMA-402 specifications.
14
14
Each proposal for an ECMAScript feature goes through the following maturity stages:
15
15
16
16
1. Stage 0: Strawman;
@@ -1151,9 +1151,9 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
1151
1151
console.log(factorial(1000));
1152
1152
console.log(factorial(10000));
1153
1153
```
1154
-
1154
+
1155
1155
**[⬆ Back to Top](#table-of-contents)**
1156
-
1156
+
1157
1157
24. ### Array find methods
1158
1158
ES6 introduced few array methods and two of them are `Array.find()` and `Array.findIndex()`.
1159
1159
@@ -1219,7 +1219,7 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
1219
1219
console.log(numbers.includes(NaN)); // true
1220
1220
console.log(numbers.includes(undefined)); // true
1221
1221
```
1222
-
1222
+
1223
1223
**[⬆ Back to Top](#table-of-contents)**
1224
1224
1225
1225
2. ### Exponentiation Operator
@@ -1266,9 +1266,9 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
1266
1266
}
1267
1267
logger();
1268
1268
```
1269
-
1269
+
1270
1270
**[⬆ Back to Top](#table-of-contents)**
1271
-
1271
+
1272
1272
2. ### Object values
1273
1273
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.
1274
1274
@@ -1286,9 +1286,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.
1294
1294
```js
@@ -1308,9 +1308,9 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
1308
1308
1309
1309
console.log(Object.entries(100)); // [], an empty array for any primitive type because it won't have any own properties
1310
1310
```
1311
-
1311
+
1312
1312
**[⬆ Back to Top](#table-of-contents)**
1313
-
1313
+
1314
1314
4. ### Object property descriptors
1315
1315
1316
1316
Property descriptors describe the attributes of a property. The `Object.getOwnPropertyDescriptors()` method returns all own property descriptors of a given object.
@@ -1334,7 +1334,7 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
@@ -1688,9 +1688,9 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
1688
1688
}
1689
1689
} catch (unused) {}
1690
1690
```
1691
-
1691
+
1692
1692
**[⬆ Back to Top](#table-of-contents)**
1693
-
1693
+
1694
1694
6. ### JSON Improvements
1695
1695
1696
1696
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.
@@ -1722,7 +1722,7 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
@@ -1957,7 +1957,7 @@ Most of these features already supported by some browsers and try out with babel
1957
1957
As per the output, each outcome object returns `status` field which denotes either "fulfilled"(value present) or "rejected"(reason present)
1958
1958
1959
1959
**[⬆ Back to Top](#table-of-contents)**
1960
-
1960
+
1961
1961
7. ### globalThis
1962
1962
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.
1963
1963
@@ -2071,7 +2071,7 @@ Most of these features already supported by some browsers and try out with babel
2071
2071
WeakRef provides two new pieces of functionality
2072
2072
1. creating weak references to objects with the WeakRef class
2073
2073
2. running user-defined finalizers after objects are garbage-collected, with the FinalizationRegistry class
2074
-
2074
+
2075
2075
**WeakRef:**
2076
2076
weak reference is a reference to an object that doesn’t prevent garbage collection if it is the only reference to the object in the memory.It’s useful when we don’t want to keep the object in memory forever(e.g, WebSocket). The main use of weak references is to implement caches or mappings to large objects for which you don't need to keep it in memory for rarely used objects.
2077
2077
@@ -2132,7 +2132,7 @@ Most of these features already supported by some browsers and try out with babel
2132
2132
2133
2133
5. ### Logical Operators
2134
2134
Logical assignment operators combines the logical operations(&&, || or ??) with assignment. They are quite useful for assigning default values to variables.
2135
-
2135
+
2136
2136
**&&=:**
2137
2137
2138
2138
The `&&=` operator performs the assignment only when the left operand is truthy.
@@ -2154,7 +2154,7 @@ Most of these features already supported by some browsers and try out with babel
2154
2154
```
2155
2155
2156
2156
**||=:**
2157
-
2157
+
2158
2158
The ||= operator performs the assignment only when the left operand is falsy.
2159
2159
```javascript
2160
2160
let x =0;
@@ -2174,7 +2174,7 @@ Most of these features already supported by some browsers and try out with babel
2174
2174
```
2175
2175
2176
2176
**??=:**
2177
-
2177
+
2178
2178
The ??= operator performs the assignment only when the left operand is null or undefined.
2179
2179
```javascript
2180
2180
let x;
@@ -2259,7 +2259,7 @@ Most of these features already supported by some browsers and try out with babel
2259
2259
2260
2260
```javascript
2261
2261
classEmployee {
2262
-
2262
+
2263
2263
constructor() {
2264
2264
this.name="John"; //public
2265
2265
this._age=35; //private
@@ -2289,7 +2289,7 @@ Most of these features already supported by some browsers and try out with babel
2289
2289
#getAge() {
2290
2290
return #age
2291
2291
}
2292
-
2292
+
2293
2293
}
2294
2294
2295
2295
constemployee=newEmployee();
@@ -2371,9 +2371,9 @@ Most of these features already supported by some browsers and try out with babel
2371
2371
**[⬆ Back to Top](#table-of-contents)**
2372
2372
2373
2373
5. ### hasOwn
2374
-
2374
+
2375
2375
The new `Object.hasOwn()` method is a replacement or improved version of `Object.prototype.hasOwnProperty`. It is a static method that returns true if the specified object has the indicated property as its own property. If the property is inherited, or does not exist, the method returns false.
2376
-
2376
+
2377
2377
It's not only more concise and readable but also overcomes the below limitations of `hasOwnProperty`.
2378
2378
2379
2379
1. **When `hasOwnProperty`overwritten:**
@@ -2407,7 +2407,7 @@ Most of these features already supported by some browsers and try out with babel
2407
2407
2. **Create an object with create(null) function:**
2408
2408
2409
2409
If you create new object with help of create(null) function, then newly created object doesn’t inherit from Object.prototype. So it doesn't have hasOwnProperty method.
2410
-
2410
+
2411
2411
Let's take an example to verify hasOwnProperty on an object created with create(null) function.
2412
2412
```javascript
2413
2413
constuser=Object.create(null);
@@ -2505,7 +2505,7 @@ Most of these features already supported by some browsers and try out with babel
2505
2505
2506
2506
console.log(weak.get(key)); //ES2023
2507
2507
```
2508
-
2508
+
2509
2509
4. ### Change array by copy
2510
2510
Both **Array** and **TypedArray** has built-in methods such as **reverse()**, **sort()** and **splice()** to perform common actions like sorting, reverse the array elements and replacing(or removing) elements. But these methods are mutating the original array. Where as ES2023 has provided additional methods such as **toReversed()**, **toSorted()**, **toSpliced** and **with()** methods which returns new array copies instead of mutating the original array.
2511
2511
@@ -2707,7 +2707,7 @@ Most of these features already supported by some browsers and try out with babel
2707
2707
After that, the notify method awakes the waiting agent(i.e, array) that are sleeping in waiting queue and the promise is fulfilled.
2708
2708
2709
2709
Remember that, SharedArrayBuffer have been disabled on most browsers unless you specify `Cross-Origin-Opener-Policy` and `Cross-Origin-Embedder-Policy` headers. For example,
2710
-
2710
+
2711
2711
`
2712
2712
Cross-Origin-Opener-Policy: same-origin
2713
2713
Cross-Origin-Embedder-Policy: require-corp
@@ -2718,7 +2718,7 @@ Most of these features already supported by some browsers and try out with babel
2718
2718
5. ### RegEx v Flag and string properties
2719
2719
6. ### Promise withResolvers
2720
2720
When you are creating a new Promise object, usually you pass `resolve` and `reject` functions to the executor of promise constructor as shown below:
0 commit comments