2014-04-01 92 views
1

我只是試着在節點repl lodash。爲什麼lodash _.without()會改變_的值?

首先,我需要lodash

_ = require('lodash') 

然後我嘗試的功能

_.without([1,2,3], 1) 
[ 2, 3 ] 

但如果我再次運行

> _.without([1,2,3], 1) 
TypeError: Object 2,3 has no method 'without' 
    at repl:1:4 
    at REPLServer.self.eval (repl.js:110:21) 
    at Interface.<anonymous> (repl.js:239:12) 
    at Interface.EventEmitter.emit (events.js:95:17) 
    at Interface._onLine (readline.js:202:10) 
    at Interface._line (readline.js:531:8) 
    at Interface._ttyWrite (readline.js:760:14) 
    at ReadStream.onkeypress (readline.js:99:10) 
    at ReadStream.EventEmitter.emit (events.js:98:17) 
    at emitKey (readline.js:1095:12) 

現在_(lodash LIB)是一個陣列?

+1

_被節點保留以存儲最後語句的值。所以你必須使用另一個變量名稱lodash var _dash = require('lodash');' – huocp

回答

相關問題