Skip to content

Instantly share code, notes, and snippets.

@kinsteronline
Created March 18, 2011 12:53
Show Gist options
  • Save kinsteronline/876018 to your computer and use it in GitHub Desktop.
Save kinsteronline/876018 to your computer and use it in GitHub Desktop.
Using this and exports in Underscore
var root = this;
// Export the Underscore object for **CommonJS**, with backwards-compatibility
// for the old `require()` API. If we're not in CommonJS, add `_` to the
// global object.
if (typeof module !== 'undefined' && module.exports) {
module.exports = _;
_._ = _;
} else {
root._ = _;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment