← Back to list

ES2021 (ES12) | Important Features

As a programmer we can only put the best performant code to the project when we know what new APIs recently introduced in the technology…

Suneet Bansal · 2023-06-11 16:21 · 16 claps · 2.6 min read
#javascript #javascript-development #es2021 #es12 #front-end-development
Open on Medium ↗
Wiki topics: 🌐 · Web Development

ES2021 (ES12) | Important Features

As a programmer we can only put the best performant code to the project when we know what new APIs recently introduced in the technology which is being used into the project.

Javascript is widely used programming language now a days in many projects of Software Industry. So it is important that we know that what important APIs introduced in every version of JS.

Lets see ES2021’s important features which we should know and could start using into project.

String replaceAll() method

Prior to ES2021, there was no direct way to replace all occurrences of a string. ES2021 has introduced replaceAll so it is very simple to achieve it.

Example-

Promise.any

This is very nice implementation added by ES2021. It can be used to run multiple promises in parallel. It gets resolved when any of the promise gets resolved or it throws “AggregateError” when all the promises gets rejected.

Example 1-

Example 2-

Promise.race

This can also be used to run multiple promises in parallel but it gets resolved once any of the promise is settled irrespective whether resolved or reject.

Example 1-

Example 2-

Logical assignment operator

The logical assignment operator combines Logical Operators and Assignment Expressions, allowing you to write a shorter syntax for variable value checking.

For example, the following code checks whether the value of x is falsy and only assign a new value when it is:

Using the logical assignment operator, you can replace the above code with the following:

The logical assignment works with nullish coalescing operator (??) as well-

Numeric Separator

This feature literally improves developer experience by enabling developers to make their numeric literals more readable by creating a visual separation between groups of digits. It’s similar to the way we use commas to separate numbers in writing.

Example-

const val = 6_23_900_1

Using the underscore, deciphering the above number becomes a no-brainer, in contrast to not using the underscore as shown below.

const val = 6239001

I hope this article will help you to understand ES2021 features better.

Note- We can now start utilizing these features into Angular/React/Vue etc framework based applications, we just need to update the compiler version and TS version wherever applicable.

Stay tuned and subscribe to my Medium Channel!!!

Thanks!


메타데이터
post_id
a89a92d12d75
slug
es2021-es12-important-features-a89a92d12d75
url
https://medium.com/@bansal.suneet/es2021-es12-important-features-a89a92d12d75
canonical_url
https://medium.com/@bansal.suneet/es2021-es12-important-features-a89a92d12d75
author_url
https://medium.com/@bansal.suneet
status
ok
fetched_at
2026-07-25 16:13:02