Last active
February 6, 2018 00:42
-
-
Save surr-name/66eba97a67cb715afe869ffe8048269f to your computer and use it in GitHub Desktop.
what will be order of numbers
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
const EventEmitter = require('events'); | |
const emiter_1 = new EventEmitter; | |
const emiter_2 = new EventEmitter; | |
process.nextTick(()=>console.log(0)); | |
setTimeout(()=>console.log(1), 0); | |
setImmediate(()=>console.log(2)); | |
emiter_1.on('event',handler.bind(null, 3)); | |
emiter_1.on('event',handler.bind(null, 4)); | |
emiter_2.on('event',handler.bind(null, 5)); | |
emiter_2.on('event',handler.bind(null, 6)); | |
emiter_1.emit('event'); | |
emiter_2.emit('event'); | |
function handler (n) { | |
const finishAt = new Date().getTime() + 200; | |
while (new Date().getTime() < finishdAt); | |
console.log(n); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment