Away Some Article
  • Home
  • Submit a Guest Post
  • Digital Marketing
  • General
  • Business
  • More
    • Web and Mobile Development
    • Write for Us Health
    • Write For Us Games, Online Gaming, Gaming Reviews
No Result
View All Result
Write for us
Away Some Article
  • Home
  • Submit a Guest Post
  • Digital Marketing
  • General
  • Business
  • More
    • Web and Mobile Development
    • Write for Us Health
    • Write For Us Games, Online Gaming, Gaming Reviews
No Result
View All Result
awaysomearticle
No Result
View All Result

New JavaScript Features in ES2021

Away Some Article by Away Some Article
February 19, 2021
in Technology, Web and Mobile Development, Web Designing
0
New JavaScript Features in ES2021
Share on FacebookShare on Twitter

There square measure 2 smart reasons for this:

  1. JavaScript is that the language of the net, and therefore the internet is chop-chop increasing.
  2. Because of this, JavaScript is receiving an incredible quantity of attention from developers World Health Organization square measure up its performance and increasing its practicality.

Here are the top new features of es2021:

1. Promise.any

Promise.any accepts a series of guarantees and is resolved as presently as any guarantees created square measure resolved. Sounds cool right? let American state show you Associate in Nursing example

Promise.any([

You might also like

edit post
Top 7 WooCommerce Development Companies in UAE

Top 7 WooCommerce Development Companies in UAE

September 29, 2023
edit post
Annotation 2023-05-10 140417

5 Ways AI is Driving Digital Transformation in Business

May 13, 2023

fetch(‘https://one.com’).then(()=>)

fetch(‘https://two.com’).then(()=>)

fetch(‘https://three.com’).then(()=>)

]).then((res)=>the guarantees was consummated

console.log() // one OR 2 OR 3

}).catch((error) = > )

})

We created 3 requests right away. once one among the requests is resolved, Promise. any additionally resolves and submits the primary application resolved to the console (for example, by Google)

If all guarantees square measure rejected, promise.any throws a replacement sort of error AggregateError.

What’s therefore new regarding the AggregateError item represents a slip once many errors square measure committed in one error.

Here’s what it’s like:

Promise.any([

fetch(‘https://one.com’).then(()=>)

fetch(‘https://two.com’).then(()=>)

fetch(‘https://three.com’).then(()=>)

]).then((res)=>the guarantees was consummated

console.log() // one OR 2 OR 3

}).catch((error) = > )

2. Logical Assignment Operator

Logical assignment operator means that it’ll be a mix of the logical operators (&&, || or ??) with the assignment.

var a = 10

var b = 20

a &&= b

console.log(a)

The result’s a pair of. on top of may be like below

a && (a = b)

OR

if(a)

It merely means if a then assign a to b , this was the instance of && during a similar fashion, we are able to use || and ??.

a &&= b

a ||= b

a ??= b

let’s inspect the instance of ||

let a = 10

let b = 20

a ||= b

console.log(a)

SO the answer is one. It may be re-written as

a || (a = b)

Let’s inspect ?? , it’s Nullish Coalescing operator and it had been in the main helpful after you ought to check if the worth isnull or indefinable.

let a

let b = a ?? five

console.log(b)

The results of this console is five At line no a pair of, if the worth of a is null or indefinable, the right-hand facet of ?? is dead and it’ll be the worth of b

Let American state offer you one complicated example?? with =

let a

let b = 2

a ??= b

console.log(x)

SO, the result’s a pair of. Here as you recognize the worth of ais indefinable. that the right-hand facet expression is dead then a can be2.

3. replaceAll()

String.prototype.replaceAll() can replace all occurrences of a string with another string worth.

As of now, JS string incorporates a replace() technique and you would possibly grasp that it may be helpful to interchange a string absolutely.

const str = “Hey Frodo, Hey Joe”

const newStr = str.replace(“Hey”, “Hello”)

console.log(newStr) // “Hello Frodo, Hey Joe”

You can see that replace() can replace solely the primary incidence within the string, not the complete, currently you would possibly wish to interchange all. What are you able to do? affirmative, one choice is you’ll be able to use RegEx or E 2021 got you,

const str = “Hey Frodo, Hey Joe”

const newStr = str.replaceAll(“Hey”, “Hello”)

console.log(newStr) // “Hello Frodo, Hello Joe”

Simple? a great deal.

4. non-public Accessor

In ES2021, to outline non-public accessor is incredibly straightforward, you simply ought to place # before the function/method name.

class automotive come “Audi” }

set name(value)

// non-public accessor

get #KMs() come 16500 }

set #age(value)

}

If you get your hands on these new options of ES2021, as of currently you’ll be able to it via the babel plugin

Logical Assignment Operator

Numeric extractor

5.WeakRef

WeakRef is that the shorthand for Weak References, and its primary use is to carry a weak relevance another object. meaning it doesn’t forestall the rubbish collector from assembling the thing. The Weak Reference is beneficial once we don’t need to stay the thing within the memory forever.

But why can we want the WeakRef within the initial place? In JavaScript, the thing isn’t collected by the rubbish collector as long as a relevance that object exists. Thus, it keeps the thing within the memory, that leaves you with less memory. The WeakRef implementation permits you to avoid that.

You can produce a Weak Reference by victimisation new WeakRef, and you’ll be able to scan a reference by career the deref() methodology. a straightforward example would be:

const largeObject = new WeakRef({

name: “CacheMechanism”,

type: “Cache”,

implementation: “WeakRef”

});

largeObject.deref();

largeObject.deref().name;

largeObject.deref().type;

largeObject.deref().implementation;

6.Numeric Separators

Working with massive numbers will quickly become confusing. as an example, take into account the quantity “92145723”. you’ve got to pay shut attention to visualize that it’s ninety two million and one thing.

With the new addition from ES2021, you’ll be able to re-write a similar variety as follows “92_145_723”. That is, you employ underscores to boost the readability. you’ll be able to see it’s already higher, and easier to know the quantity. Now, you’ll be able to clearly see it’s ninety two million and one thing.

Therefore, the numeric apparatus feature is just for rising readability. It doesn’t have an effect on the performance of your application negatively or absolutely.

// previous syntax before ES12

const variety = 92145723;

// new syntax coming back with ES12

const variety = 92_145_723;

7.BigInt

BigInt is one among the foremost anticipated options in JavaScript that is currently finally here. It really permits developers to possess abundant larger whole number illustration in their JS code for processing for knowledge handling.

8.Dynamic import

Dynamic imports in JavaScript natively offer you the choice to import JS files dynamically as modules in your application. this is often a bit like however you are doing it with Webpack and Babel at the instant.

9.Nullish Coalescing

Nullish coalescing adds the flexibility to really check nullish values rather than falsey values. what’s the distinction between nullish and falsey values, you would possibly ask?

In JavaScript, a great deal of values square measure falsey, like: empty strings, the quantity zero, undefined, null, false, NaN, etc.

10.Optional Chaining

Optional chaining syntax permits you to access deeply nested object properties without concern if the property exists or not. If it exists, great! If not, you will get indefinable came.

11.String#matchAll

matchAll may be a new technique superimposed to the String epitome that is expounded to Regular Expressions. This returns Associate in Nursing iterator that returns all matched teams one when another.

Tags: New JavaScriptNew JavaScript Features in ES2021
Away Some Article

Away Some Article

Away Some Article is an experienced writer who has written a plethora of articles, based on technology. Her extensive knowledge about Technology is evident from the articles, written in this blog. you need submit a guest post?, then contact us

Related Stories

edit post
Top 7 WooCommerce Development Companies in UAE

Top 7 WooCommerce Development Companies in UAE

by Away Some Article
September 29, 2023
0

The categorical surge in the demand for consumer trade through digital means in the Middle East, particularly in the UAE,...

edit post
Annotation 2023-05-10 140417

5 Ways AI is Driving Digital Transformation in Business

by Away Some Article
May 13, 2023
0

In today's fast-paced and ever-changing business landscape, digital transformation has become a necessity for organizations looking to stay ahead of...

edit post
Hotel Website Design in Thailand: Choosing the Perfect Company to Meet Your Needs

Hotel Website Design in Thailand: Choosing the Perfect Company to Meet Your Needs

by Away Some Article
March 21, 2023
1

As a hotelier in Thailand, creating an online presence is essential for staying competitive in today's digital landscape. A well-designed...

edit post
Top 10 WordPress SEO Tips & Techniques to Boost Rankings

Why WordPress Development Services Essential for Your Business?

by Away Some Article
March 12, 2023
0

As a business owner, you may wonder if investing in WordPress Development Services is worth it. The answer is yes!...

Next Post
edit post
avery-klein-JaXs8Tk5Iww-unsplash

Ultimate Guide To Your Design-Build Luxury Home

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Submit A Guest post | Away Some Article & Blog

Useful Links

  • About Us
  • Contact us
  • Latest Article
  • Privacy Policy
  • Disclaimer
  • DMCA Policy

Follow us

Populer Posts

edit post
Top AI Remote Companies in Arizona

Top AI Remote Companies in Arizona

October 10, 2025
edit post

Top Automotive Companies in Arizona

September 8, 2025
edit post
Top-Free-Dating-Apps

Top Dating Apps Without Subscription: Experience Unique Match Making for Free

September 8, 2025
edit post
Top Finance & Payments Companies in Arizona

Top Finance & Payments Companies in Arizona

October 10, 2025

Browse Category

Beauty Business Career Content Management System Digital Marketing Digital Marketing Trends 2020 Drupal 8 Drupal 9 eCommerce Businesses Fashion Finance Games General Gift Google Flutter Guest Post Guest Posting Hair Care Tips Health Home Home improvement Interior Design Jobs Lifestyle Magento 2 Magento 2 App Development Mobile & Web Development Mobile App Development Online Business Real Estate SEO SEO Digital Marketing Social Media Social Media Marketing Software Technology Tips Travel Traveling Uncategorized Web and Mobile Development Web Designing Web Development Web Development Services Yoga

Copyright © 2025 Away Some Article. All rights reserved.

No Result
View All Result
  • Home
  • Submit a Guest Post
  • Digital Marketing
  • General
  • Business
  • Mobile App Development
  • Web and Mobile Development
  • Write For Us Games, Online Gaming, Gaming Reviews
  • Contact us

Copyright © 2025 All rights reserved.