O'Reilly logo
  • Shinji Abe thinks this is interesting:

var fs = require("fs");

fs.readFile("foo.txt", "utf8", function(error, data) {
  if (error) {
    throw error;


console.log("Reading file...");

This short example illustrates two important conventions for Node developers. First, if a method takes a callback function as an argument, it should be the final argument. Second, if a method takes an error as ...


Cover of Pro Node.js for Developers