Last active
January 25, 2019 21:53
-
-
Save hamg26/23bd4f582d7db595833d935aa0655e33 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Really cool conferences here: | |
// https://www.youtube.com/watch?v=8aGhZQkoFbQ | |
// https://www.youtube.com/watch?v=cCOL7MC4Pl0 | |
/********* | |
1 | |
*********/ | |
for ( var i = 0; i < 3; i++) { | |
setTimeout( function() { console.log(i); }, i * 1000 ); | |
} | |
// should log `3` 3 times | |
// http://latentflip.com/loupe/?code=Zm9yICggdmFyIGkgPSAwOyBpIDwgMzsgaSsrKSB7CiAgICBzZXRUaW1lb3V0KCBmdW5jdGlvbigpIHsgY29uc29sZS5sb2coaSk7IH0sIGkgKiAxMDAwICk7ICAKfQ%3D%3D!!!PGJ1dHRvbj5DbGljayBtZSE8L2J1dHRvbj4%3D | |
/********* | |
2 | |
*********/ | |
( function() { | |
console.log(10); | |
setTimeout( function(){console.log(20)}, 1000); | |
setTimeout( function(){console.log(30)}, 0); | |
console.log(40); | |
} )(); | |
// should log `10` and `40` (those are executed first because they are sent to the stack inmediatly) | |
// should log `30` after, waits 0 miliseconds for the timeout to complete (the stack needs to be empty first) | |
// should log `20` after, waits 1000 miliseconds for the timeout to complete (the stack needs to be empty first) | |
// http://latentflip.com/loupe/?code=KCBmdW5jdGlvbigpIHsgIAogIGNvbnNvbGUubG9nKDEwKTsgIAogIHNldFRpbWVvdXQoIGZ1bmN0aW9uKCl7Y29uc29sZS5sb2coMjApfSwgMTAwMCk7ICAKICBzZXRUaW1lb3V0KCBmdW5jdGlvbigpe2NvbnNvbGUubG9nKDMwKX0sIDApOyAgCiAgY29uc29sZS5sb2coNDApOyAgCn0gKSgpOw%3D%3D!!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment