Junior From PDF Node.js Node.js

What is the difference between synchronous and asynchronous functions?

  • Synchronous functions block the execution until they finish.
  • Asynchronous functions allow other code to run while waiting for operations (like

I/O) to complete.

// Synchronous (blocks event loop)

const data = fs.readFileSync('file.txt');

// Asynchronous (non-blocking)

fs.readFile('file.txt', (err, data) => {

if (err) throw err;

console.log(data);

});

More from Node.js Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details