SHARE THIS POST
This article will explore some interesting ECMA Spec proposals that have reached stage 4 and may be added to the next ECMAScript Spec release. Shall we?
If you are familiar with the Lodash groupBy method or the SQL GROUP BY clause, you’d easily understand what this proposal aims to achieve. This proposal seeks to give ECMAScript the ability to combine data into groups.
This groupBy method would be accessible as properties in the Object and Map data structure. For example, say you want to group an array of objects based on the type property; you could do this using the groupBy method.
The above code sample uses the groupBy method to group an array of animals and persons into their respective groups. This would be a wonderful addition to the ECMA Spec as it would make it a little straightforward. This method also has a polyfill available here if you’d like to play around with it
This proposal provides array methods that make changes to arrays without mutating the original array. It returns a copy of the array containing the changes. The change array copy proposal is finished and has been merged to the ECMAScript spec and is available in ES2023.
It provides methods to sort, reverse and change array data without mutating the array these data are contained in but returns a new copy of the array with the change. Here is an example using the toReversed method
Here is an example of Temporal immutability compared to the Date object using a Temporal polypill
The immutability of Temporal helps to prevent unexpected modifications to the date/time data.
You can find more proposals in the official ECMAScript proposal repo here.
Back to top