刚刚开始使用 Node.js,并想尝试使用 Underscore 来测试一些想法。
我明白为什么_
在 REPL 中使用 不起作用。但也不会重新分配下划线对象。
例如,
> 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]);
回报:
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)
除了重命名全局下划线对象之外,关于为什么这不起作用的任何想法?分配给的版本_u
是1.0.2。