Created
March 19, 2017 20:57
-
-
Save barcicki/13b4774a9ee12d5f06639e45ea5a9572 to your computer and use it in GitHub Desktop.
Call order test
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
function test(name, depths = 1) { | |
console.log(name); | |
if (depths > 0) { | |
setImmediate(() => test(`${name} > setImmediate`, depths - 1)); | |
setTimeout(() => test(`${name} > setTimeout`, depths - 1)); | |
process.nextTick(() => test(`${name} > nextTick`, depths - 1)); | |
Promise.resolve().then(() => test(`${name} > resolve`, depths - 1)); | |
} | |
} | |
test('Start', 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment