Explain the difference between readFile and createReadStream in Node.js.
Instruction: Compare readFile and createReadStream in terms of their operation and use cases.
Context: This question measures the candidate's understanding of the file system in Node.js, focusing on the differences between reading files using readFile and streams.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
readFile is a method that reads the entire content of a file into memory before making it available. When you call readFile, Node.js loads the whole file content into RAM at once, and only upon completion, it invokes the callback function with the content...