Created
October 12, 2021 01:37
-
-
Save rainabba/5784f79261b1686dc13dcb851588e2b8 to your computer and use it in GitHub Desktop.
Clarifying javascript execution order
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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