title: Extending Array.prototype in Node.js, from a require'd file
body: <p>I have the following saved in test.js.  It successfully extends Array in the browser, but it doesn't seem to work with node and require.  Can someone explain what's wrong here?</p>
  
  <pre><code>(function() {
  
  Array.prototype.max = function() {
    return console.log("Array.prototype.max");
  };
  return Array.max = function() {
    return console.log("Array.max");
  };
  
  }).call(this);
  </code></pre>
  
  <p>Then, from a terminal:</p>
  
  <pre><code>&gt; My-MacBook-Pro: me$ node
  &gt; var test = require("./test")
  &gt; [1,2,3].max()
  TypeError: Object 1,2,3 has no method 'max'
      at [object Context]:1:9
      at Interface.&lt;anonymous&gt; (repl.js:171:22)
      at Interface.emit (events.js:64:17)
      at Interface._onLine (readline.js:153:10)
      at Interface._line (readline.js:408:8)
      at Interface._ttyWrite (readline.js:585:14)
      at ReadStream.&lt;anonymous&gt; (readline.js:73:12)
      at ReadStream.emit (events.js:81:20)
      at ReadStream._emitKey (tty_posix.js:307:10)
      at ReadStream.onData (tty_posix.js:70:12)
  &gt; Array.max()
  TypeError: Object function Array() { [native code] } has no method 'max'
      at [object Context]:1:7
      at Interface.&lt;anonymous&gt; (repl.js:171:22)
      at Interface.emit (events.js:64:17)
      at Interface._onLine (readline.js:153:10)
      at Interface._line (readline.js:408:8)
      at Interface._ttyWrite (readline.js:585:14)
      at ReadStream.&lt;anonymous&gt; (readline.js:73:12)
      at ReadStream.emit (events.js:81:20)
      at ReadStream._emitKey (tty_posix.js:307:10)
      at ReadStream.onData (tty_posix.js:70:12)
  </code></pre>