can someone please explain what's the exports variable for:
copied from backbone.js, I also noticed spine.js uses the same pattern.
https://gist.github.com/1375748
var Backbone;
if (typeof exports !== 'undefined') {
Backbone = exports;
} else {
Backbone = root.Backbone = {};
}
That module pattern is part of the CommonJS specification called CommonJS Modules :
In a module, there is a free variable called "exports", that is an object that the module may add its API to as it executes.
So basically adding to the exports object defines the API your module exposes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.