Welcome to JS Bin
Load cached copy from
 
// ------- Setup-code -------
const someAsyncFunction1 = () => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      resolve();
    }, 1000);
  });
}
const someAsyncFunction2 = someAsyncFunction1;
const someAsyncFunction3 = someAsyncFunction1;
const someAsyncFunction4 = someAsyncFunction1;
// ------- Test-code -------
console.log('log1');
someAsyncFunction1()
  .then(() => {
    console.log('log3');
    return someAsyncFunction2();
  })
  .then(() => {
    console.log('log4');
    return someAsyncFunction3();
  })
  .then(() => {
    console.log('log5');
    return someAsyncFunction4()
  })
  .then(() => {
    console.log('log6');
  });
console.log('log2');
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x