Javascript 为什么';t主干网使用module.exports?
看起来它用的是普通的Javascript 为什么';t主干网使用module.exports?,javascript,backbone.js,Javascript,Backbone.js,看起来它用的是普通的 导出而不是模块。导出 在这一行 但是,这将显示正在使用的模块.exports 主干网为什么不使用module.exports 因为它不必这样做 尤其是module.exports与exports对象相同 如果您可以保存几个字符来输入,那么为什么不这样做呢 当您使用document.getElementById而不是window.document.getElementById时,您也在这样做。它更多的是打字,没有增加任何好处 在本教程中,他们使用的是module.expor
导出
而不是模块。导出
在这一行
但是,这将显示正在使用的模块.exports
主干网为什么不使用module.exports
因为它不必这样做
尤其是module.exports
与exports
对象相同
如果您可以保存几个字符来输入,那么为什么不这样做呢
当您使用document.getElementById
而不是window.document.getElementById
时,您也在这样做。它更多的是打字,没有增加任何好处
在本教程中,他们使用的是
module.exports
,因为他们想显示导出符号与导出的区别,即
exports.foo = bar;
并覆盖导出
对象
module.exports = bar;
您必须使用module.exports
(exports=bar;
不起作用)。想想浏览器中的module
像窗口一样。实际上,它们基本上是一样的
因此,与浏览器中javascript中执行的window.location===location
相同,节点环境中的module.exports===exports
。exports
和module.exports
是相同的。。。。不确定这是否与。。。看起来module是全局变量。在浏览器/客户端上,类窗口是全局变量。那么为什么代码不是Backbone=root.exports。在这种情况下,root将指向module。每个文件都是全局的。或每个文件的本地。不管你怎么说。
module.exports = bar;