1. What is the meaning of Promise
2. What states are there in the internal state machine of Promise, and how do the states flow and how do the changes between states be triggered
3. How does Promise realize the state change from then to catch to THEN
How do I get the following two lines of code to execute sequentially without skipping either method
. then().catch().then(); . then().catch().catch().then();Copy the code
4. What is the difference between the Promise asynchronous queue and the setTimeout asynchronous queue, which has a higher priority
5. Wrap the setTimeout method with a Promise
6. Use method and conditions of async await
7. How do I make a method support await keyword while keeping synchronous execution
Modify the following methods to support await test(1, 2); (Requirement: A + B must be executed synchronously)
function test(a, b) {
return a + b;
}
Copy the code
8. How to make a Promise successful before starting another Promise (not to use await)
In the real world, after a successful API call, the return value is used as the parameter of the next API call and the response value of the second API is returned
Function getData() {api1(). Then ((resp1) => {}); function getData() {api1(). /* Please complete the rest of the code... */ } getData().then((resp2) => {});Copy the code