7 amazing new features in ES14 (2023)
Ever since 2015, a new JavaScript version has come out every year with tons of powerful features to make life much easier, and 2023 has been no different. Let’s look at what ES14 has to offer.
And just like sort(), toSorted() takes a callback function that lets you decide how the sort should happen - ascending or descending, alphabetical or numeric.2. Hashbang grammar
What’s a hashbang?
Basically, it’s a sequence of characters in a file that tells the Linux Shell what interpreter or engine it should use to run the file. For example:
codingbeauty.shCopied!With this hashbang, we can now easily run codingbeauty.sh directly in the shell, after using the chmod command to make the script executable.
Hashbangs also let us hide all the juicy implementation details in our scripts and indicate specific interpreter versions to execute the script files.
So with ES14, we can now do t4. Symbols as WeakMap keys
WeakMaps; not very popular, are they?
Well, they’re a lot like Maps, except their keys can only contain non-primitive objects — no strings or numbers allowed here. These keys are stored as weak references, meaning the JavaScript engine can carry out garbage collection on the objects when it needs to if there is no other reference to the objects in memory apart from the keys.
One powerful use of WeakMaps is custom caching: by using objects as keys, you can associate cached values with specific objects. When the objects are garbage collected, the corresponding WeakMap entries are automatically removed, clearing the cache immediately.his effortlessly in JavaScript files, like this:
0 Comments