[英]Why doesn't backbone use module.exports?
Why doesn't backbone use module.exports? 为什么主干不使用module.exports?
Because it doesn't have to. 因为它没有。 exports
and module.exports
refer to the same object : exports
和module.exports
引用相同的对象 :
In particular
module.exports
is the same as theexports
object. 特别是module.exports
与exports
对象相同。
If you can save a couple of characters to type, then why not do it? 如果您可以保存几个字符进行输入,那么为什么不这样做呢?
You are doing the same when you use document.getElementById
instead of window.document.getElementById
. 使用document.getElementById
而不是window.document.getElementById
时,您正在执行相同的操作。 It's more to type and doesn't add any benefit. 打字更多,不会增加任何好处。
In the tutorial they are using module.exports
because they want to show the difference between exporting a symbol why exports
, ie 在本教程中,他们使用的是module.exports
因为他们想显示出口的象征,为什么之间的差额exports
,即
exports.foo = bar;
and overwriting the exports
object 并覆盖 exports
对象
module.exports = bar;
for which you have to use module.exports
( exports = bar;
would not work). 您必须使用module.exports
( exports = bar;
不起作用)。
Think of module
like window
in a browser. 在浏览器中考虑像window
一样的module
。 In actuality, they're basically the same thing. 实际上,它们基本上是一回事。
So, in the same way that window.location === location
in javascript executed in the browser, module.exports === exports
in a node environment. 因此,与浏览器中执行的javascript中的window.location === location
相同, module.exports === exports
在节点环境中module.exports === exports
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.