• About Us
  • Privacy & Policy
  • Terms and Conditions
  • Contact
Away Some Article & Blog
  • Home
  • Mobile App Development
  • WordPress
  • Yoga
  • General
  • Lifestyle
  • Health
  • SEO
  • Write For Us
  • Contact us
  • More
    • Business
    • Web and Mobile Development
    • Digital Marketing
    • Career
    • Earn Money Online
    • Education
    • Finance
    • Hair Care Tips
    • Internet
    • Jobs
No Result
View All Result
  • Home
  • Mobile App Development
  • WordPress
  • Yoga
  • General
  • Lifestyle
  • Health
  • SEO
  • Write For Us
  • Contact us
  • More
    • Business
    • Web and Mobile Development
    • Digital Marketing
    • Career
    • Earn Money Online
    • Education
    • Finance
    • Hair Care Tips
    • Internet
    • Jobs
No Result
View All Result
Away Some Article & Blog
No Result
View All Result
Home Technology

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

ADVERTISEMENT

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) = > )

})

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
Previous Post

A Quick 10-Step Guide to Website Optimization

Next Post

Ultimate Guide To Your Design-Build Luxury Home

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, as written in this blog. you need submit a guest post?, then contact us

Next 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 *

Subscribe To Our Newsletter

  • Trending
  • Comments
  • Latest

Coin master free spin and coin links

March 6, 2021
Latest And Most Exciting Trends In Mobile App Design In 2020

Latest And Most Exciting Trends In Mobile App Design In 2020

August 8, 2020
austin-distel-VwsuhJ9uee4-unsplash

6 Things You Must Know Before Starting an Online Business

August 23, 2020
How to Estimate the Time, Cost, and Deliverables of an ML App Project

How to Estimate the Time, Cost, and Deliverables of an ML App Project

August 1, 2020
Getting Amazing Results on your Carpet Without a Steam Cleaner

Getting Amazing Results on your Carpet Without a Steam Cleaner

2
How to calculate returns on FDs?

How to calculate returns on FDs?

2
Dissertation Writing Help

Most Common Problems Students Face With Writing Dissertations

2
hair-growth-long-hair-stock-today-180622-main-art_698aa92eb44df10ec28944776bdbc015.fit-760w

Learn How to Grow Hair Fast

2
Data Analytics VS Data Science: Definition, Differences, and Career Opportunities

Data Analytics VS Data Science: Definition, Differences, and Career Opportunities

March 5, 2021
Top 10 WordPress Tips For Beginners in 2021

Top 10 WordPress Tips For Beginners in 2021

March 5, 2021
Top 10 WordPress SEO Tips & Techniques to Boost Rankings

Top 10 WordPress SEO Tips & Techniques to Boost Rankings

March 5, 2021
Why Startups & Entrepreneurs Need Project Management in 2021?

Why Startups & Entrepreneurs Need Project Management in 2021?

March 4, 2021

Recent Blog

Data Analytics VS Data Science: Definition, Differences, and Career Opportunities

Data Analytics VS Data Science: Definition, Differences, and Career Opportunities

March 5, 2021
Top 10 WordPress Tips For Beginners in 2021

Top 10 WordPress Tips For Beginners in 2021

March 5, 2021
Top 10 WordPress SEO Tips & Techniques to Boost Rankings

Top 10 WordPress SEO Tips & Techniques to Boost Rankings

March 5, 2021
Why Startups & Entrepreneurs Need Project Management in 2021?

Why Startups & Entrepreneurs Need Project Management in 2021?

March 4, 2021
ADVERTISEMENT
Away Some Article & Blog

Submit A Guest post | Away Some Article & Blog

Follow Us

Browse by Category

  • Accounting
  • Accounting software
  • Architecture
  • Automobile
  • Automotive
  • Beauty
  • Best Exercises
  • Biography
  • Bitcoin
  • Blockchain
  • Business
  • Career
  • CBD
  • Computer
  • Content Management System
  • Corona virus
  • COVID-19
  • Dentist
  • Designing
  • Digital Marketing
  • Digital Marketing Trends 2020
  • Drupal 8
  • Drupal 9
  • Earn Money Online
  • eCommerce Businesses
  • Education
  • Electronics
  • Entertainment
  • Face
  • Facebook
  • Fashion
  • Finance
  • FinTech apps
  • Fitness
  • Food
  • Furniture
  • Gadgets
  • Games
  • Gardening
  • General
  • Gift
  • Google Flutter
  • Graphic Design Services
  • Graphics Cards
  • Guest Post
  • Guest Posting
  • Gym
  • Hair Care Tips
  • Health
  • Holiday Accommodation
  • Home improvement
  • Household
  • Interior Design
  • Internet
  • Jewelry
  • JioMart News
  • Jobs
  • Kitchen
  • Laravel Development
  • Law
  • Legal
  • Lifestyle
  • Loan
  • Magento 2
  • Magento 2 App Development
  • Marketing
  • Medical
  • Medical Store
  • Men's Health
  • Mental Health
  • Mobile & Web Development
  • Mobile App Development
  • Mobile Recharge
  • Movies
  • Moving and relocation
  • MVP Development
  • News
  • Office Furniture
  • Online Business
  • Other
  • Park
  • Party
  • Photography
  • Psychologist
  • RAKHI
  • Real Estate
  • Recruitment Services
  • Restaurant
  • Restoration Company
  • Rose
  • SEO
  • Skin
  • Smartphones
  • Social Media
  • Social Media Marketing
  • Software
  • Sport
  • Teaching
  • Technology
  • Telecom
  • Tiles
  • Tips
  • Travel
  • Traveling
  • Uncategorized
  • Use Integrity Scanning
  • Villa
  • VoIP
  • Web and Mobile Development
  • Web Designing
  • Web Development Services
  • Website development
  • Women
  • Wordpress
  • Yoga
  • Yoga Therapy

Recent Article

Data Analytics VS Data Science: Definition, Differences, and Career Opportunities

Data Analytics VS Data Science: Definition, Differences, and Career Opportunities

March 5, 2021
Top 10 WordPress Tips For Beginners in 2021

Top 10 WordPress Tips For Beginners in 2021

March 5, 2021
Top 10 WordPress SEO Tips & Techniques to Boost Rankings

Top 10 WordPress SEO Tips & Techniques to Boost Rankings

March 5, 2021
Why Startups & Entrepreneurs Need Project Management in 2021?

Why Startups & Entrepreneurs Need Project Management in 2021?

March 4, 2021
How to Choose the Right iPhone App Development Company for Your Business?

How to Choose the Right iPhone App Development Company for Your Business?

March 4, 2021

Buy Steroids, But For Positive Use

March 4, 2021
PRINCE2 Practitioners on Telecom Applications – A Real Security Hole?

PRINCE2 Information Security Projects aren’t Enough to Protect You Online

March 2, 2021
  • About Us
  • Privacy & Policy
  • Terms and Conditions
  • Contact

Copyright © 2020 Away Some Article. All rights reserved.

No Result
View All Result
  • Home
  • Magento 2 App Development
  • WordPress
  • SEO
  • Yoga
  • Lifestyle
  • Health
  • Write For Us
  • Contact us

Copyright © 2020 Away Some Article. All rights reserved.