how to async javascript stack overflow

Solutions on MaxInterview for how to async javascript stack overflow by the best coders in the world

showing results for - "how to async javascript stack overflow"
Melina
18 Jun 2019
1function makePromise(x) { 
2    return new Promise(resolve => {
3      setTimeout(() => {
4        resolve(x);
5      }, 1000);
6    });
7  }
8  
9  async function asyncFunc() {
10    var x = await makePromise(1); // the function is paused here until the promise is fulfilled
11    console.log(x); // logs 1
12    return x;
13  }
14  
15  const returnedProm = asyncFunc(); // the async func returns a promise
16
17
18  returnedProm.then((x) => console.log(x));
19  // This promise is fulfilled with the return value from the async func, so this logs 1
Lotta
28 Oct 2018
1window.setTimeout(function() {
2    console.log("World");
3}, 1000);
4console.log("Hello");
5