Extending Array.prototype in Node.js, from a require'd file
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? (function() { Array.prototype.max = function() { return console.log("Array.prototype.max"); }; return Array.max = function() { return console.log("Array.max"); }; }).call(this); Then, from a terminal: > My-MacBook-Pro: me$ node > var test = require("./test") > [1,2,3].max() TypeError: Object 1,2,3 has no method 'max' at [object Context]:1:9 at Interface.<anonymous> (repl.js:171:22) at Interface.emit (events.js:64:17) at