pharmaopk.blogg.se

Ecmascript 2021
Ecmascript 2021







ecmascript 2021

catch(console.error) //All of the promises were rejected.Ĭonst first = await Promise.any(promises) // Any of the promises was fulfilled. Promise.any(promises) // Any of the promises was fulfilled. const myFetch = url => setTimeout(() => fetch(url), Math.floor(Math.random() * 3000)) This is similar to Pormise.race, except any doesn’t reject early when one of the promises rejects. Promise.any gives you a signal as soon as one of the promises fulfills.

ecmascript 2021

const fruits = '🍎+🍐+🍓+' Ĭonst fruitsWithBanana = fruits.replaceAll('+', '🍌') const fruits = '🍎+🍐+🍓+' Ĭonst fruitsWithBanana = fruits.replace(/\+/g, '🍌') Ĭonsole.log(fruitsWithBanana) //🍎🍌🍐🍌🍓🍌Ī new replaceAll method has been added to the String prototype. New updates: The new JavaScript features in ECMAScript 2021 are as follows. The new JavaScript features in ES2021 are:Ĭurrently there is no way to replace all instances of a substring in a string without use of a global regexp (/regexp/g). It provides new functions, simple ways to do complex work, and much more. Of course, it’s necessary to have a basic knowledge of JavaScript to fully understand the best ones introduced. In this way, you can quickly understand the new features without the need for a complex explanation. This article introduces the features provided by ES2021 in easy code examples. However, some useful features have been incorporated. This version doesn’t include as many new features as those that appeared in ES6 (2015). In this series, we are going to show the EcmaScript features from 2015 to today.ĮS2021 is the version of ECMAScript corresponding to the year 2021. ZExtra ES2021 Features in simple examples









Ecmascript 2021