What's new in ECMAScript 2020 ?

Whats new in ecma 2020 2021 javascript

Here comes another update to the EVER-CHANGING world of JAVASCRIPT.
In this article, we are going to review recent additions to the feature list of Javascript.

1. Promise.allSettled

The Promise.allSettled() method is the newest addition to the feature's provided by javascript in ECMA 2020.

allSettled() returns a promise that resolves after all of the given promises have either resolved or rejected, with an array of objects that each describes the outcome of each promise.With Promise.allSettled(), we can create a new promise that only returns when all of the promises passed to it are complete. This will give us access to an array with some data on each promise.


2. Nullish Coalescing Operator

As you guys already know, Javascript is a dynamically typed language. It is a well-known fact that we need to keep truthy/falsy values in mind when we are doing a variable assignment. If we have an object with some values, sometimes we want to allow values that are technically wrong(falsy), like an empty string or the number 0. Pipe operators in this case fail. Pipes are used to assigning default values even if the value was 0 or an empty string. This was really very annoying when your empty string value was not falsy or you didn't want to assign a default value in case of 0. For Example - 

Nullish Coalescing Operator

Now, from ECMA 2020 we can use Nullish Coalescing Operator ( ?? ) to overcome this problem. Nullish Coalescing Operator provides a more type strict way to assign a default value. Nullish Coalescing Operator only assigns default when the value is null or undefined.

whats new in javascript

3. BigInt

In terms of features, he called ECMAScript 2020 is a much bigger update than 2019.
“We have a lot more syntax proposals in there, and we have big things like 
BigInt.”BigInt is a built-in object that provides a way to represent whole numbers larger than 253 - 1, which is the largest number JavaScript can reliably represent with the Number primitive and represented by the Number.MAX_SAFE_INTEGER constant. BigInt can be used for arbitrarily large integers.
A BigInt is created by appending n to the end of an integer literal — 10n — or by calling the function BigInt().
bigInt in javascript

4. Dynamic Import

Finally, with ECMA Script 2020 it is possible to dynamically import dependencies in the project.
If you had a file full of utility functions, some of them may rarely be used and importing all of their dependencies could just be a waste of resources. Now we can use async/await to dynamically import our dependencies when we need them.

dynamic import in javascript

5.  Optional Chaining Operator

Just like Nullish coalescing operator, Javascript doesn't act how we wish to when dealing with falsy values. We can return a value if we want is undefined, but what if the path to it is undefined?

Now with ECMAScript 2020 we can add a question mark before our dot notation we can make any part of a value's path optional so we can still interact with it.

whats new in ecma 2020


These are the main features that are introduced in ECMA 2020. Now you can start using these amazing features by adding these from babel/ polyfills or perhaps confusing your coworkers with JavaScript features that aren’t even in most browsers, yet (unless they are if you are reading this from the future). 

Thanks for reading, please feel free to contact us. 

Click to join our Facebook Page

Click to join us on our Telegram

Click to join us on our Facebook Group

You can check out our most active blogs as well.