title: node.js: Cannot read property 'defaultEncoding' of undefined
body: <p>I wanted to write a changeable write() function.</p>
  
  <pre><code>var write = function(s) {
      process.stdout.write(s);
  }
  write("Hello world!");
  </code></pre>
  
  <p>I thought you could just write it shorter:</p>
  
  <pre><code>var write = process.stdout.write;
  write("Hello world!");
  </code></pre>
  
  <p>But here I will receive this error:</p>
  
  <pre><code>TypeError: Cannot read property 'defaultEncoding' of undefined
      at Writable.write (_stream_writable.js:172:21)
      at Socket.write (net.js:613:40)
      at repl:1:2
      at REPLServer.self.eval (repl.js:110:21)
      at Interface.&lt;anonymous&gt; (repl.js:239:12)
      at Interface.EventEmitter.emit (events.js:95:17)
      at Interface._onLine (readline.js:202:10)
      at Interface._line (readline.js:531:8)
      at Interface._ttyWrite (readline.js:760:14)
      at ReadStream.onkeypress (readline.js:99:10)
  </code></pre>
  
  <p>Why is that?</p>