Answers for "how to async javascript stack overflow"

0

async await javascript stack overflow

function makePromise(x) { 
    return new Promise(resolve => {
      setTimeout(() => {
        resolve(x);
      }, 1000);
    });
  }
  
  async function asyncFunc() {
    var x = await makePromise(1); // the function is paused here until the promise is fulfilled
    console.log(x); // logs 1
    return x;
  }
  
  const returnedProm = asyncFunc(); // the async func returns a promise


  returnedProm.then((x) => console.log(x));
  // This promise is fulfilled with the return value from the async func, so this logs 1
Posted by: Guest on February-25-2020
0

how to async javascript stack overflow

window.setTimeout(function() {
    console.log("World");
}, 1000);
console.log("Hello");
Posted by: Guest on September-03-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language