Here Are What You Should Know About ES10

Image for post
Image for post

What is ES10 (ES2019)?

Q: But what is ECMAScript anyway?

A: It is a scripting language specification standardized by Ecma International. It’s the language spec that Javascript is based on. In other words, Javascript is just an implementation of this spec. There are other implementations out there, but by far, Javascript is the most popular.

Q: But why do they have to come up with that?

A: As you know, there are a lot of browsers out there. Each has its own Javascript Engine for executing JavaScript code. For example: With Microsoft Edge, we have Chakra, with Firefox we have SpiderMonkey and with Chrome we have V8. If each of them has its own way to run Javascript code then it will be really messy. One website might be working perfectly in this Chrome but completely broken in Microsoft Edge.

At the end of this article, we will show you how to always be well informed and up to date about all the newest Javascript features. Let’s start reading.

Some of ES10 new features

1. Array.flatMap():

This method combines map and flat and allows you to map through the item of the array. First, it will try to map every element of the array using the old mapping function. After that, it flattens the returned result into a brand new array which is quite useful in some cases.

For example:

Image for post
Image for post

2. Object.fromEntries():

For example:

Image for post
Image for post

3. Optional Catch Binding:

Before ES10, we use to write code like this:

You have some try/catch statement and let’s say you don’t want to catch the error or you don’t care what kind of error that you’re getting there.

Image for post
Image for post

You could see that the error parameter here is required. In the previous version, it doesn’t really matter where you use this param or not, it will always be needed.

It seems nice at first glance but it’s also quite controversial. We would recommend you research deeper on some related posts but since it’s out of scope for this article, we will keep it simple.

However, with ES10, we could be more flexible by writing code like this with try/catch:

Image for post
Image for post

As you can see, there is not a single parameter on the catch method. It makes sense when you know you’re not going to use the exception object.

4. String.trimStart() & String.trimEnd():

Image for post
Image for post
Image for post
Image for post

The trimEnd() does the same thing but at the end of our string.

Having the two methods will be extremely helpful when you deal with string. You might use them to remove a string from inputting data from the client such as email, username, or name.

5. Function.toString():

When possible, it could read your source code, otherwise, it will return some “placeholder”. The idea is that this “placeholder” should not be evaluable. So if you try to make this “placeholder” to behave like a real function by calling it or passing arguments to it, it will return a syntax error.

In the future, you could not guarantee that this “placeholder” wouldn’t become syntactically valid in some coming versions of Javascript. Also, please keep in mind that white spaces or newlines or event comments will not appear in the result. In real-world scenarios, we might rarely have to use that, but it would add more power for us as developers for debugging purposes.

Always stay up to date with Javascript

A: There is a TC39 ECMAScript proposals repository in Github. TC39 is a committee responsible for Javascript evolution. In this repo, you will find the document for the ECMAScript proposals in 4 stages starting from stage 0 which is a strawman.

When a proposal gets some illustrative example and gets some high-level API to describe, it can transition to stage 1. At stage 1, it’s actually a proposal. Then proposal transitions to stage 2 where it has to have the least initial text spec. In stage 3, it’s already a candidate and its spec should be completed, reviewed and approved. Finally, stage 4 is the finished line. If a proposal gets to this stage, it means that it will be included in the next edition of the next ECMAScript standard.

Just check out the repo from time to time, read the proposals and be on the bleeding edge of Javascript!

Written by

Designveloper is leading software development company in Vietnam. We offer Web development, mobile application, UI/UX Design, VOIP. www.designveloper.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store