Created
June 2, 2017 16:19
-
-
Save grawk/9f878826dc51a873adcb05b1b00eb25e to your computer and use it in GitHub Desktop.
nextTick
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
var queue = []; | |
for (var i = 0; i < 10; i++) { | |
queue.push(function () { | |
process.nextTick(function () { | |
console.log(Date.now()); | |
(queue.length > 0) ? queue.shift()() : null; | |
}); | |
}); | |
} | |
queue.shift()(); | |
console.log('after'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment