Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the new features of V8 8.5

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article focuses on "what are the new features of V8 8.5". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn what are the new features of V8 8.5.

Promise.any

Promise adds an any method that receives an array of Promise, and when one of the Promise in the array is fulfilled, the Promise it returns is returned.

Const promises = [fetch ('/ endpoint-a'). Then (() = >'a'), fetch ('/ endpoint-b'). Then (()) = >'b'), fetch ('/ endpoint-c'). Then (() = >'c'),]; try {const first = await Promise.any (promises); / / any Promise is fulfilled status console.log (first) / / → 'b'} catch (error) {/ / all Promise are rejected console.assert (error instanceof AggregateError); / / reject result array console.log (error.errors);}

If all input Promise is rejected, Promise.any will return an exception of type AggregateError, and the errors property of this object contains all Promise rejected properties.

Be careful not to be confused with the Promise.race method, the race method is that any Promise in the array is resolved or rejected, while the any method must be resolved, and an exception is thrown if all are rejected.

String.prototype.replaceAll

String.prototype.replaceAll provides an easy way to replace all matches of substrings without having to create a global RegExp.

Look at the following example. In the past, to replace all the + in queryString, you need to create a global regular:

Const queryString = 'qroomqueryqualified parameters; queryString.replace (/\ + / g,'')

Now you just need to use the replaceAll method:

QueryString.replaceAll ('+','')

Logical assignment operator

The logical assignment operator is a new compound assignment operator, which can take the logical operation & &, | or? Combined with the assignment operation into a single command.

X & & = y; / / equivalent to x & & (x = y) x | | = y; / / equivalent to x | (x = y) x? = y; / equivalent to x? (X = y) at this point, I believe you have a deeper understanding of "what are the new features of V8 8.5". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report