Filesystem & Core Utilities
Core filesystem and path APIs and their impact on Node.js execution.
Q52: What is the difference between fs.readFile and fs.readFileSync?
fs.readFile reads files asynchronously without blocking the Event Loop. fs.readFileSync blocks code execution until reading completes.
Key Takeaways
fs.readFileis non-blocking asynchronous I/O.fs.readFileSyncblocks the main thread during file reading.
Knowledge Check
Which method should be avoided in production HTTP request handlers?
Q53: What is the difference between path.join() and path.resolve()?
path.join() joins all given path segments together using platform separators. path.resolve() resolves path segments into an absolute path, treating segments as roots if prefixed with /.
Key Takeaways
path.join()concatenates path segments normalized.path.resolve()constructs absolute paths working right-to-left.
Knowledge Check
Which path method always returns an absolute path string?