Skip to content

Instantly share code, notes, and snippets.

@rainabba
Created October 12, 2021 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rainabba/5784f79261b1686dc13dcb851588e2b8 to your computer and use it in GitHub Desktop.
Save rainabba/5784f79261b1686dc13dcb851588e2b8 to your computer and use it in GitHub Desktop.
Clarifying javascript execution order
console.time('full execution');
console.time('code block');
function showExecutionOrder(parm) {
console.time('outside promise');
new Promise((resolve, reject) => {
console.time('inside promise');
resolve(parm);
console.timeEnd('inside promise');
}).then((data) => {
// Lookup mdn and invoke the account sync as required
console.log({ data });
});
console.timeEnd('outside promise');
}
console.time('function call');
showExecutionOrder({ foo: true });
console.timeEnd('function call');
console.timeEnd('code block');
console.timeEnd('full execution');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment