async-await

Async and await are used together
1Parallel processing
2Error handling
Reprinted from:
Note: async and await are used together, and the function after await is executed to execute the next js code.
example:

function sleep(second) {
   return new Promise((resolve, reject) => {
       setTimeout(() => {
           resolve(' enough sleep~');
       }, second);
   })
}
function normalFunc() {
   console.log('normalFunc');
}
async function awaitDemo() {
   await normalFunc();
   console.log('something, ~~');
   let result = await sleep(2000);
   Console.log(result);// will be printed after two seconds
console.log(3)
}
awaitDemo();

 result:
normalFunc
something, ~~
enough sleep~
3

Intelligent Recommendation

Database SQL combat 1: Find all the information of the latest employees

thought: The topic asks to find all the information of the latest employees. Through a sub-query (select max(hire_date) from employees), find the latest hire time of the employee, hire_date, and then ...

Correction of TOPSIS model based on entropy weight method

Recently, I am learning mathematical modeling and found a very good course on B station. It is very comprehensive and all the algorithms I often test involve:Qingfeng Mathematical Modeling This articl...

51nod longest common subsequence output path +

When x = 0 or y = 0 when f [x] [y] = 0 When a [x] = b [y] when f [x] [y] = f [x-1] [y-1] +1 When a [x]! = B [y] when f [x] [y] = max (f [x] [y-1], f [x-1] [y]) Note that the string 1 from the start, b...

Enumeration algorithm summary

I learned the enumeration algorithm in this section. The enumeration method is the nature of the problem itself, and all possible solutions are listed in one by one, and in the process of listed one b...

More Recommendation

Two value methods for Map of Java brushing knowledge points: keySet and entrySet, HashMap, Hashtable, TreeMap, LinkedHashMap, ConcurrentHashMap, Weak...

  The interface java.util.Map includes three implementation classes: HashMap, Hashtable, and TreeMap. Of course there are LinkedHashMap, ConcurrentHashMap, WeakHashMap.   Map is used to storeKey-value...

Everyday fresh items

Everyday fresh items - project preference Understand the e-commerce Web project development process Project demand analysis Page page Function map Deployment page Project framework Understand the e-co...

The easiest way: install opencv on windows platform python, that is to achieve import cv2 function

The following old method used before installed opencv, after reinstalling the system, reinstalled opencv according to the original method, and the result has always been reported: ImportError: Module ...

Matlab programming skills: reading and writing text files

Various text files are involved in MBD (model-based design), and the automated processing of text files can greatly improve work efficiency. This article briefly introduces the first step of processin...

Mysql opens a remote connection

1. Log in to Mysql cmd enter mysql -u root -pyoupassword (Input rule After you press Enter, you will be prompted to enter the password. Note that there may or may not be spaces before the user name, b...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top