Tyl*_*son 7 node.js underscore.js read-eval-print-loop
所以当我发现一些非常奇怪的东西时,我正在玩Node.js REPL和Underscore库.如果我require("underscore"),变量_是全局设置的(显然).然后,当我尝试运行一个像console.log(_.isEmpty)它打印的简单命令时[Function](显然,再次).但是,在运行console.log(_)之后,它会打印,[Function]因为变量_设置为_.isEmpty.
为什么这样做?如果我从js文件运行相同的代码,这不会发生.这是一个普通的Node节点还是这个bug?
仅供参考:节点v0.10.10
SLa*_*aks 13
节点的REPL始终设置_为最后一行的结果.
> 2
2
> _
2
> 2+2
4
> _
4
>
Run Code Online (Sandbox Code Playgroud)
您需要使用不同的标识符:
var u = require("underscore");
u.isEmpty
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1086 次 |
| 最近记录: |