Read Time:1 Minute, 18 Second

Today we will cover some new features that wew added in Javascript !

BigInt

BigInt is a special numeric type that provides support for integers of arbitary Length .

const bigint = 123456789098765454456745757n ;

const sameBigint = BigInt(123456789098765454456745757n);

const bigIntFromNumber = BigInt(10);

Dynamic Import

Import js files dynamically as modules in your application .

if (myCondition) {
    const module = await import('./dynamicmodule.js')
}

Nullish Coalescing

The ability to truly check nullish values instead of falsey values .

let name = null ;

name ?? "Short dev tips" ; //Short dev tips

Optional Chaining

Access deeply nested object properties without worrying if the property exists or not .

const devTips = {
    name : "Omer Arafat" ,
    tags : {
      instagram : '@arafatomer66'
 }
};

devTips.tags?.instagram ;

devTips.tags?.youtube; //undefined

Promise.AllSettled

Accepts an array of Promises and only resolves when all of them are settled (Resolved or Rejected) .

var ApiCall1 = fetch(" url1 ");
var ApiCall1 = fetch(" url2 ");

Promise.allSettled([ApiCall1 , ApiCall2]).then( result => {
   result => forEach(result => {
      console.log(result);
 });
});

GlobalThis

Alwasy refers to the global object , No matters where you are executing your code .

if(typeof globalThis.setTimeout !== "function") {
  // no setTimeout in this environment
}

String.matchAll

Returns a iteration which returns all matched groups one after another .

let regexp = /t(e)(st(\d?))/ ;
let str = "test" ;

let array = [...str.matchAll(regexp)] ;

console.log(array[0]) ; 

FOR-IN Mechanics

The ECMA specification did not specify i which order for (x in y) should run in js . Even though browsers implemented a consistent order on their own before now , This has been offically standardized in ES2020 .

HAVE YOU USED ANY BEFORE , LET ME KNOW IN THE COMMENT SECTION !!

0 0
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleppy
Sleppy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Leave a Reply

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

Close