WBE_Praktikum_5/code/async/immediate.js

23 lines
388 B
JavaScript
Raw Permalink Normal View History

2022-10-27 08:21:03 +02:00
//
// timeout vs immediate
//
const fs = require('fs')
setTimeout(() => {
console.log('timeout')
}, 0)
setImmediate(() => {
console.log('immediate')
})
fs.readFile("immediate2.js", () => {
setTimeout(() => {
console.log('timeout from readFile callback')
}, 0)
setImmediate(() => {
console.log('immediate from readFile callback')
})
})
console.log('script started')