Because in nodejs REPL _ is the result of the last expression. You should not use _ for anything in nodejs REPL.
why does lodash _.without() change the value of _?
-
25-06-2023 - |
Domanda
I am just trying out lodash in the node repl.
First I require lodash
_ = require('lodash')
Then I try one of the functions
_.without([1,2,3], 1)
[ 2, 3 ]
But if I run it again
> _.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)
Now _ (lodash lib) is an array?
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow