Skip to content

Instantly share code, notes, and snippets.

@andrewlistopadov
Last active November 16, 2018 09:07
Show Gist options
  • Select an option

  • Save andrewlistopadov/53b0ec622be7848466084b5fcd90402d to your computer and use it in GitHub Desktop.

Select an option

Save andrewlistopadov/53b0ec622be7848466084b5fcd90402d to your computer and use it in GitHub Desktop.
function getRejectedPromise() {
const promise = new Promise((resolve, reject) => {
reject('some error');
});
return promise;
}
let counter = 0;
const interval = setInterval(() => {
if (++counter > 10) clearInterval(interval);
else console.log(`async counter: ${counter}`);
}, 500);
getRejectedPromise()
.then(() => console.log('Never be called. But rejection will not be visible in the console and main thread will be alive.'));
console.log('will be reached');
setTimeout(() => console.log('2nd async console output'), 3000);
setTimeout(() => console.log('1 async console output'), 0);
setTimeout(() => console.log('last async console output'), 6000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment