What is the difference between async and sync code in Node.js?
Sync code blocks the main thread until it completes. Async code returns immediately and runs a callback when done, letting the event loop process other work. Always prefer async for I/O operations.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Node.js Interview Questions Every Beginner Should Know
Node.js is a JavaScript runtime built on Chrome's V8 engine that runs JavaScript on the server. It uses libuv for async I/O and an event loop to process callbacks non-blockingly on a single thread.
A single-threaded loop that processes callbacks from completed async operations. It is what makes Node.js non-blocking and efficient for concurrent I/O, since the main thread is not blocked waiting for operations to complete.
They are Node.js's CommonJS module system. module.exports exports values from a file, and require imports them. This is how Node.js code is split into reusable modules across files.
Still have questions?
Browse all our FAQs or reach out to our support team
