Question: You have to read a large text file, replace some words in it, and write it back to a new file. You know that the memory on your target system is limited. What should you do?

  1. Use regular expressions directly on the file.
  2. Use Promises and async/await to offload the task to libuv.
  3. Copy the file into a database and perform the operations there.
  4. Use readline together with streams to read and transform and write the file contents line by line.

Answer: The correct answer of the above question is Option D:Use readline together with streams to read and transform and write the file contents line by line.