WBE_Praktikum_5/code/async/nexttick.js

22 lines
334 B
JavaScript
Raw Normal View History

2022-10-27 08:21:03 +02:00
//
// nexttick vs. immediate and timeout events
//
const fs = require('fs')
const process = require('process')
fs.readFile("nexttick.js", () => {
setTimeout(() => {
console.log('timeout')
}, 0)
setImmediate(() => {
console.log('immediate')
})
process.nextTick(() => {
console.log('nexttick')
})
})