Just getting started with Node.js and would like to try out Underscore to test out some ideas.
I've read post here, here and lastly here.
I get why using the _
does not work in a REPL. But neither does reassigning the underscore object.
For instance,
> var _u = require('underscore');
{ _:
{ [Function]
VERSION: '1.0.2',
forEach: [Function],
map: [Function],
reduce: [Function],
reduceRight: [Function],
detect: [Function],
...feeling good about myself...
> _u.uniq([1,2,3,4,4,44]);
Returns:
TypeError: Object #<Object> has no method 'uniq'
at repl:1:4
at REPLServer.self.eval (repl.js:109:21)
at rli.on.self.bufferedCmd (repl.js:258:20)
at REPLServer.self.eval (repl.js:116:5)
at Interface.<anonymous> (repl.js:248:12)
at Interface.EventEmitter.emit (events.js:96:17)
at Interface._onLine (readline.js:200:10)
at Interface._line (readline.js:518:8)
at Interface._ttyWrite (readline.js:736:14)
at ReadStream.onkeypress (readline.js:97:10)
Any ideas on why this could not work besides rename the global underscore object? The version assigned to _u
is 1.0.2.
1.0.2
has got to be pretty old. 1.4.2
is the current version. I'd bet that this method simply doesn't exist on that version of the library.
Time to upgrade.