Created
January 30, 2019 19:56
-
-
Save bilalucar/48dc0b0718ebb5fc06caf804f67a1664 to your computer and use it in GitHub Desktop.
JavaScript Deeper Understanding
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
function main(){ | |
console.log('A'); | |
setTimeout( | |
function exec(){ console.log('B'); } | |
, 0); | |
runWhileLoopForNSeconds(3); | |
console.log('C'); | |
} | |
main(); | |
function runWhileLoopForNSeconds(sec){ | |
let start = Date.now(), now = start; | |
while (now - start < (sec*1000)) { | |
now = Date.now(); | |
} | |
} | |
// Output | |
// A | |
// C | |
// B |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment