Skip to content

Instantly share code, notes, and snippets.

@bilalucar
Created January 30, 2019 19:56
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 bilalucar/48dc0b0718ebb5fc06caf804f67a1664 to your computer and use it in GitHub Desktop.
Save bilalucar/48dc0b0718ebb5fc06caf804f67a1664 to your computer and use it in GitHub Desktop.
JavaScript Deeper Understanding
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