看起来它只是简单地使用
exports代替module.exports
在这行这里。
if (typeof exports !== 'undefined') {
Backbone = exports;
但是,本教程显示了module.exports正在使用的内容。
为什么骨干网不使用 module.exports?
因为没必要。exports并module.exports引用同一个对象:
特别
module.exports是exports对象相同。
如果您可以保存几个字符来输入,那为什么不这样做呢?
当您使用document.getElementById而不是window.document.getElementById. 打字更多,并没有增加任何好处。
在他们使用的教程中,module.exports因为他们想显示导出符号之间的区别exports,即
exports.foo = bar;
并覆盖exports对象_
module.exports = bar;
您必须使用module.exports(exports = bar;不起作用)。
想像在浏览器中module。window实际上,它们基本上是一样的。
因此,与window.location === location在浏览器中执行的 javascript 中的方式相同,module.exports === exports在节点环境中。