0
剛開始使用Node.js,並想嘗試Underscore來測試一些想法。節點REPL + 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。
更新:'npm update underscore' – JohnnyHK
感謝您放縱我的無知。更新像魅力一樣工作。 – rhodee