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
+91Lines changed: 91 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,7 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
32
32
| ES2020 Or ES11 | June 2020 |
33
33
| ES2021 Or ES12 | June 2021 |
34
34
| ES2022 Or ES13 | June 2022 |
35
+
| ES2023 Or ES14 | June 2023 |
35
36
36
37
### Table of Contents
37
38
@@ -110,6 +111,11 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
110
111
|4 |[Error cause](#error-cause)|
111
112
|5 |[hasOwn](#has-own)|
112
113
|6 |[Regex match indices](#regex-match-indices)|
114
+
||**ES2023 Or ES14**|
115
+
|1 |[Find array from last](#find-array-from-last)|
116
+
|2 |[Hashbang syntax](#hashbang-syntax)|
117
+
|3 |[Symbols as WeakMap keys](#symbols-as-weakmap-keys)|
118
+
|4 |[Change Array by Copy](#change-array-by-copy)|
113
119
114
120
## ES2015 Or ES6
115
121
@@ -2430,4 +2436,89 @@ Most of these features already supported by some browsers and try out with babel
2430
2436
console.log(result[0]); // ['Jack', 'Jack', index: 8, input: 'Authos: Jack, Alexander and Jacky', groups: undefined, indices: Array(2)]
2431
2437
```
2432
2438
2439
+
**[⬆ Back to Top](#table-of-contents)**
2440
+
2441
+
## ES2023 Or ES14
2442
+
ECMAScript 2023 or ES14 has been released in the month of June 2023 with some of important features like adding new methods for searching and altering the arrays, supporting symbols as keys for WeakMap API and standardizing the hashbang syntax in JavaScript.
2443
+
2444
+
1. ### find-array-from-last
2445
+
2446
+
This release introduced two new array methods named **findLast()** and **findLastIndex()** to search an array element from the last. Their functionality is similar to **find()** and **findIndex()** but searching starts from the end of an array. These methods are available on **Array** and **TypedArray** prototypes. This feature provides an efficient way for reverse order search by eliminating the process of manual array reversal.
2447
+
2448
+
For example, let's see the usage of finding odd elements from end of an array prior to ES2023. There are no direct methods available to search element from end of an array. Hence, the array needs to be reversed first before applying **first()** and **firstIndex()** methods.
This process is going to be simiplified in ES2023 release using **findLast()** and **findLastIndex()** methods.
2459
+
2460
+
```javascript
2461
+
constisOdd= (number) => number %2===1;
2462
+
constnumbers= [1, 2, 3, 4, 5];
2463
+
2464
+
console.log(numbers.findLast(isOdd)); // 5
2465
+
console.log(numbers.findLastIndex(isOdd)); // 4
2466
+
```
2467
+
2468
+
2. ### hashbang-syntax
2469
+
Hashbang(as known as shebang) grammer has been supported with a sequence of characters(#!) at the beginning of an executable script to define the interpreter for the program to run. In other words, this syntax is helpful to tell the operating system which interpreter to use while executing the script.
2470
+
2471
+
For example, the below javacript file will be executed in NodeJS interpreter from Unix commandline.
2472
+
```javascript
2473
+
#!/usr/bin/env node
2474
+
'use strict';
2475
+
console.log("Hello world from hashbang syntax");
2476
+
```
2477
+
3. ### symbols-as-weakmap-keys
2478
+
Prior to ES2023, WeakMaps are only limited to allow objects as keys because objects are unique and cannot be re-created. Since symbols are the only primitives in ECMAScript that allows unique values, WeakMap API has been extended with symbols as keys instead of just using objects.
2479
+
2480
+
As an example, the usage of WeakMap with objects as keys prior to ES2023 looks like below
2481
+
```javascript
2482
+
constweak=newWeakMap();
2483
+
constobjKey= { x:10 };
2484
+
2485
+
weak.set(objKey, "ES2023");
2486
+
console.log(weak.get(objKey)); //ES2023
2487
+
```
2488
+
In ES2023, it is possible to use symbols as keys
2489
+
```javascript
2490
+
constweak=newWeakMap();
2491
+
constkey=Symbol("ref");
2492
+
weak.set(key, "ES2023");
2493
+
2494
+
console.log(weak.get(key)); //ES2023
2495
+
```
2496
+
4. ### change-array-by-copy
2497
+
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.
2498
+
2499
+
For example, these additional methods returns new array copies for number array without mutating the original array as shown below,
0 commit comments