Skip to content

Instantly share code, notes, and snippets.

@re4388
Created August 1, 2022 12:32
Show Gist options
  • Save re4388/3ff061f378d2f153f9f24a2079b1aca0 to your computer and use it in GitHub Desktop.
Save re4388/3ff061f378d2f153f9f24a2079b1aca0 to your computer and use it in GitHub Desktop.
const promise = new Promise((resolve, reject) => {
console.log(1);
resolve(5);
console.log(2);
}).then(val => {
console.log(val);
});
promise.then(() => {
console.log(3);
});
console.log(4);
setTimeout(function () {
console.log(6);
});
ans: 1, 2, 4, 5, 3, 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment